2015-06-24 10:15:51 +00:00
|
|
|
#include <json.hpp>
|
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-06-24 10:15:51 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create a JSON value
|
|
|
|
json value = {{"array", {1, 2, 3, 4}}};
|
|
|
|
|
|
|
|
// create an array_t
|
|
|
|
json::array_t array = {"Snap", "Crackle", "Pop"};
|
|
|
|
|
|
|
|
// swap the array stored in the JSON value
|
|
|
|
value["array"].swap(array);
|
|
|
|
|
|
|
|
// output the values
|
|
|
|
std::cout << "value = " << value << '\n';
|
|
|
|
std::cout << "array = " << array << '\n';
|
|
|
|
}
|