max_size.cpp 707 B

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