{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/399","repository_url":"https://api.github.com/repos/nlohmann/json","labels_url":"https://api.github.com/repos/nlohmann/json/issues/399/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/399/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/399/events","html_url":"https://github.com/nlohmann/json/issues/399","id":196526937,"number":399,"title":"Finding a value in an array","user":{"login":"pboettch","id":442684,"avatar_url":"https://avatars.githubusercontent.com/u/442684?v=3","gravatar_id":"","url":"https://api.github.com/users/pboettch","html_url":"https://github.com/pboettch","followers_url":"https://api.github.com/users/pboettch/followers","following_url":"https://api.github.com/users/pboettch/following{/other_user}","gists_url":"https://api.github.com/users/pboettch/gists{/gist_id}","starred_url":"https://api.github.com/users/pboettch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pboettch/subscriptions","organizations_url":"https://api.github.com/users/pboettch/orgs","repos_url":"https://api.github.com/users/pboettch/repos","events_url":"https://api.github.com/users/pboettch/events{/privacy}","received_events_url":"https://api.github.com/users/pboettch/received_events","type":"User","site_admin":false},"labels":[{"id":46374235,"url":"https://api.github.com/repos/nlohmann/json/labels/kind:%20question","name":"kind: question","color":"cc317c","default":false},{"id":344572510,"url":"https://api.github.com/repos/nlohmann/json/labels/state:%20help%20needed","name":"state: help needed","color":"fbca04","default":false},{"id":304694104,"url":"https://api.github.com/repos/nlohmann/json/labels/state:%20waiting%20/%20please%20discuss","name":"state: waiting / please discuss","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-12-19T21:38:01Z","updated_at":"2016-12-21T07:07:35Z","closed_at":null,"body":"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.\r\n\r\n    #include <json.hpp>\r\n    using json = nlohmann::json;\r\n    int main(void)\r\n    {\r\n    \tjson j({\"hello\", \"world\"});\r\n    \tstd::cerr << j << \"\\n\";\r\n    \tstd::cerr << (j.find(\"hello\") != j.end()) << \" expecting 1\\n\";\r\n    \tfor (const auto &i: j)\r\n    \t\tif (i == \"hello\")\r\n    \t\t\tstd::cerr << \"found it while iterating\\n\";\r\n        return 0;\r\n    }\r\n\r\nit gives\r\n\r\n    [\"hello\",\"world\"]\r\n    0 expecting 1\r\n    found it while iterating\r\n\r\nReading json.hpp I saw that `find()` is often done with a key. What is the expected behavior of finding on an array?\r\n"},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/268452463","html_url":"https://github.com/nlohmann/json/issues/399#issuecomment-268452463","issue_url":"https://api.github.com/repos/nlohmann/json/issues/399","id":268452463,"user":{"login":"nlohmann","id":159488,"avatar_url":"https://avatars.githubusercontent.com/u/159488?v=3","gravatar_id":"","url":"https://api.github.com/users/nlohmann","html_url":"https://github.com/nlohmann","followers_url":"https://api.github.com/users/nlohmann/followers","following_url":"https://api.github.com/users/nlohmann/following{/other_user}","gists_url":"https://api.github.com/users/nlohmann/gists{/gist_id}","starred_url":"https://api.github.com/users/nlohmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlohmann/subscriptions","organizations_url":"https://api.github.com/users/nlohmann/orgs","repos_url":"https://api.github.com/users/nlohmann/repos","events_url":"https://api.github.com/users/nlohmann/events{/privacy}","received_events_url":"https://api.github.com/users/nlohmann/received_events","type":"User","site_admin":false},"created_at":"2016-12-21T07:07:35Z","updated_at":"2016-12-21T07:07:35Z","body":"So basically this is what I wrote in https://github.com/nlohmann/json/issues/399#issuecomment-268208449:\r\n\r\n- @TurpentineDistillery proposes to throw when `find` is used with an array (\"throw an exception if called on the \"wrong\" value type\")\r\n- @whackashoe proposes to actually search in an array and return an iterator and (\"defining the missing behavior\")\r\n\r\nAny more opinions?"}}
{"actor":{"display_login":"nlohmann"}}