Skip to content

json_pointer construction bug #1786

@shtinkov

Description

@shtinkov

Hi,
I think i hit a bug in json_pointer construction with nlohmann::json 3.7.0.
When i call json.contains with "/objects/account/actions/select"_json_pointer it works perfect, but calling it with already constructed json_pointer gives false result.
Here is how to reproduce:

#include "json.hpp"
#include <iostream>

int main() {
  nlohmann::json test;
  test["objects"]["account"]["actions"]["select"]=65;
  std::string jsonp="/objects/account/actions/select";
  nlohmann::json::json_pointer jp(jsonp);
  std::cout << test << std::endl;
  std::cout << "Is it found with "<< jp<< " : " <<  test.contains(jp) << std::endl;
  std::cout << "Is it found now: " <<  test.contains("/objects/account/actions/select"_json_pointer) << std::endl;
  return 0;
}

Output of this is:

{"objects":{"account":{"actions":{"select":65}}}}
Is it found with "/objects/account/actions/select" : 0
Is it found now: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: duplicatethe issue is a duplicate; refer to the linked issue insteadsolution: proposed fixa fix for the issue has been proposed and waits for confirmation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions