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.

29 lines
878 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create JSON values
  6. json j_null;
  7. json j_boolean = true;
  8. json j_number_integer = 17;
  9. json j_number_float = 23.42;
  10. json j_object = {{"one", 1}, {"two", 2}};
  11. json j_object_empty(json::value_t::object);
  12. json j_array = {1, 2, 4, 8, 16};
  13. json j_array_empty(json::value_t::array);
  14. json j_string = "Hello, world";
  15. // call empty()
  16. std::cout << std::boolalpha;
  17. std::cout << j_null.empty() << '\n';
  18. std::cout << j_boolean.empty() << '\n';
  19. std::cout << j_number_integer.empty() << '\n';
  20. std::cout << j_number_float.empty() << '\n';
  21. std::cout << j_object.empty() << '\n';
  22. std::cout << j_object_empty.empty() << '\n';
  23. std::cout << j_array.empty() << '\n';
  24. std::cout << j_array_empty.empty() << '\n';
  25. std::cout << j_string.empty() << '\n';
  26. }