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.

17 lines
484 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create JSON objects
  6. json j_no_init_list = json::object();
  7. json j_empty_init_list = json::object({});
  8. json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
  9. //json j_invalid_list = json::object({ "one", 1 }); // would throw
  10. // serialize the JSON objects
  11. std::cout << j_no_init_list << '\n';
  12. std::cout << j_empty_init_list << '\n';
  13. std::cout << j_list_of_pairs << '\n';
  14. }