You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
466 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create a JSON object
  6. json j_object = {{"one", 1}, {"two", 2}};
  7. // call find
  8. auto count_two = j_object.count("two");
  9. auto count_three = j_object.count("three");
  10. // print values
  11. std::cout << std::boolalpha;
  12. std::cout << "number of elements with key \"two\": " << count_two << '\n';
  13. std::cout << "number of elements with key \"three\": " << count_three << '\n';
  14. }