-
Hello Here is my jSON object
And In C# I can query on json object like this var srchItem = UsersJSONObject.SelectToken("$.users[?(@.name == 'umar')]"); Then it return this in srchitem
Then I can easily access any key value from srchitem like this
Would you please help me how I can do this in c++ using nlohmann |
Beta Was this translation helpful? Give feedback.
Answered by
nlohmann
Apr 29, 2021
Replies: 1 comment 3 replies
-
This library does not support that functionality (I think it's call JSON Path). You would need to live with C++ algorithms. Assuming you parsed the JSON to variable auto it = std..find_if(j["users"].begin(), j["users"].end(), [](const json& el) {
return el["name"] == "umar";
});
if (it != j["users"].end())
{
std::cout << (*it)["name"] << "\n";
} (untested) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
nlohmann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This library does not support that functionality (I think it's call JSON Path).
You would need to live with C++ algorithms. Assuming you parsed the JSON to variable
j
:(untested)