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
426 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. // serialize without indentation
  9. std::cout << j_object << "\n\n";
  10. std::cout << j_array << "\n\n";
  11. // serialize with indentation
  12. std::cout << std::setw(4) << j_object << "\n\n";
  13. std::cout << std::setw(2) << j_array << "\n\n";
  14. }