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
505 B

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