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.

28 lines
835 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 size()
  16. std::cout << j_null.size() << '\n';
  17. std::cout << j_boolean.size() << '\n';
  18. std::cout << j_number_integer.size() << '\n';
  19. std::cout << j_number_float.size() << '\n';
  20. std::cout << j_object.size() << '\n';
  21. std::cout << j_object_empty.size() << '\n';
  22. std::cout << j_array.size() << '\n';
  23. std::cout << j_array_empty.size() << '\n';
  24. std::cout << j_string.size() << '\n';
  25. }