basic_json__basic_json.cpp 338 B

1234567891011121314151617
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create a JSON array
  7. json j1 = {"one", "two", 3, 4.5, false};
  8. // create a copy
  9. json j2(j1);
  10. // serialize the JSON array
  11. std::cout << j1 << " = " << j2 << '\n';
  12. std::cout << std::boolalpha << (j1 == j2) << '\n';
  13. }