2017-07-09 09:51:38 +00:00
|
|
|
#include <iostream>
|
2018-02-01 21:20:26 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-06-24 10:15:51 +00:00
|
|
|
|
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';
|
|
|
|
}
|