contains.cpp 527 B

1234567891011121314151617
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create some JSON values
  7. json j_object = R"( {"key": "value"} )"_json;
  8. json j_array = R"( [1, 2, 3] )"_json;
  9. // call contains
  10. std::cout << std::boolalpha <<
  11. "j_object contains 'key': " << j_object.contains("key") << '\n' <<
  12. "j_object contains 'another': " << j_object.contains("another") << '\n' <<
  13. "j_array contains 'key': " << j_array.contains("key") << std::endl;
  14. }