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

find is error #32

Closed
lonerwolf opened this issue Jan 20, 2015 · 5 comments
Closed

find is error #32

lonerwolf opened this issue Jan 20, 2015 · 5 comments
Assignees
Labels
solution: invalid the issue is not related to the library

Comments

@lonerwolf
Copy link

json o;
o["foo"] = 23;
o["bar"] = false;
o["baz"] = 3.141;

// find an entry
if (o.find("foo") != o.end()) {
// there is an entry with key "foo"
}

in my example

key:"Heart_COL"
type:"HEX"
val:"DF01140234340000"

auto it = jsonData.find("type");
std::cout << *it << '\n';
the printf data is "Heart_COL"

@lonerwolf
Copy link
Author

@nlohmann

@nlohmann
Copy link
Owner

I'll check tonight.

@nlohmann nlohmann self-assigned this Jan 20, 2015
@nlohmann
Copy link
Owner

I do not really understand your problem. I tried the following code:

json jsonData = {{"Heart_COL", "DF01140234340000"}};
auto it = jsonData.find("type");
//std::cout << *it << '\n'; will throw, because it == json.end()
it = jsonData.find("Heart_COL");
std::cout << *it << '\n'; // prints "DF01140234340000"
std::cout << it.key() << '\n'; // prints Heart_COL
std::cout << it.value() << '\n'; // prints "DF01140234340000"
std::cout << it->get<std::string>() << '\n'; // prints DF01140234340000

What did you try to achieve in your code? What went wrong?

@nlohmann
Copy link
Owner

@lonerwolf, could you please comment?

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Jan 24, 2015
@nlohmann
Copy link
Owner

I close this issue until the problem is clear.

GerHobbelt pushed a commit to GerHobbelt/nlohmann-json that referenced this issue May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants