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.

18 lines
514 B

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