• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <nlohmann/json.hpp>
3 
4 using json = nlohmann::json;
5 
main()6 int main()
7 {
8     // create a JSON value
9     json value = {{"array", {1, 2, 3, 4}}};
10 
11     // create an array_t
12     json::array_t array = {"Snap", "Crackle", "Pop"};
13 
14     // swap the array stored in the JSON value
15     value["array"].swap(array);
16 
17     // output the values
18     std::cout << "value = " << value << '\n';
19     std::cout << "array = " << array << '\n';
20 }
21