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.

24 lines
678 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_array = {1, 2, 4, 8, 16};
  12. json j_string = "Hello, world";
  13. // call max_size()
  14. std::cout << j_null.max_size() << '\n';
  15. std::cout << j_boolean.max_size() << '\n';
  16. std::cout << j_number_integer.max_size() << '\n';
  17. std::cout << j_number_float.max_size() << '\n';
  18. std::cout << j_object.max_size() << '\n';
  19. std::cout << j_array.max_size() << '\n';
  20. std::cout << j_string.max_size() << '\n';
  21. }