-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Milestone
Description
I started using nlohmann::json today (thanks for it) and I wanted to check whether a certain value is contained in an array: I used find(). It compiled but it does not work.
#include <json.hpp>
using json = nlohmann::json;
int main(void)
{
json j({"hello", "world"});
std::cerr << j << "\n";
std::cerr << (j.find("hello") != j.end()) << " expecting 1\n";
for (const auto &i: j)
if (i == "hello")
std::cerr << "found it while iterating\n";
return 0;
}
it gives
["hello","world"]
0 expecting 1
found it while iterating
Reading json.hpp I saw that find() is often done with a key. What is the expected behavior of finding on an array?
Reactions are currently unavailable