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.

23 lines
457 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create stream with serialized JSON
  6. std::stringstream ss;
  7. ss << R"({
  8. "number": 23,
  9. "string": "Hello, world!",
  10. "array": [1, 2, 3, 4, 5],
  11. "boolean": false,
  12. "null": null
  13. })";
  14. // create JSON value and read the serialization from the stream
  15. json j;
  16. j << ss;
  17. // serialize JSON
  18. std::cout << std::setw(2) << j << '\n';
  19. }