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.

20 lines
551 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create JSON values
  6. json j_object = {{"one", 1}, {"two", 2}};
  7. json j_array = {1, 2, 4, 8, 16};
  8. // call dump()
  9. std::cout << j_object.dump() << "\n\n";
  10. std::cout << j_object.dump(-1) << "\n\n";
  11. std::cout << j_object.dump(0) << "\n\n";
  12. std::cout << j_object.dump(4) << "\n\n";
  13. std::cout << j_array.dump() << "\n\n";
  14. std::cout << j_array.dump(-1) << "\n\n";
  15. std::cout << j_array.dump(0) << "\n\n";
  16. std::cout << j_array.dump(4) << "\n\n";
  17. }