Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_pointer construction bug #1786

Closed
shtinkov opened this issue Oct 10, 2019 · 2 comments
Closed

json_pointer construction bug #1786

shtinkov opened this issue Oct 10, 2019 · 2 comments
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@shtinkov
Copy link

shtinkov commented Oct 10, 2019

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
@nlohmann
Copy link
Owner

This seems to be a duplicate of #1727 which is fixed in the develop version and will be released as version 3.7.1 some time soon. Running with that code, I get the output

Is it found with "/objects/account/actions/select" : 1
Is it found now: 1

@nlohmann nlohmann added solution: duplicate the issue is a duplicate; refer to the linked issue instead solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Oct 13, 2019
@shtinkov
Copy link
Author

Thank you very much!
I will wait for 3.7.1
Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants