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.

19 lines
415 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create a JSON value
  6. json value = {{"array", {1, 2, 3, 4}}};
  7. // create an array_t
  8. json::array_t array = {"Snap", "Crackle", "Pop"};
  9. // swap the array stored in the JSON value
  10. value["array"].swap(array);
  11. // output the values
  12. std::cout << "value = " << value << '\n';
  13. std::cout << "array = " << array << '\n';
  14. }