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.

30 lines
550 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create JSON value
  6. json j =
  7. {
  8. {"pi", 3.141},
  9. {"happy", true},
  10. {"name", "Niels"},
  11. {"nothing", nullptr},
  12. {
  13. "answer", {
  14. {"everything", 42}
  15. }
  16. },
  17. {"list", {1, 0, 2}},
  18. {
  19. "object", {
  20. {"currency", "USD"},
  21. {"value", 42.99}
  22. }
  23. }
  24. };
  25. // call flatten()
  26. std::cout << std::setw(4) << j.flatten() << '\n';
  27. }