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