This is an example of how to create a JSON object with Metall.
#include <iostream>
{
"pi": 3.141,
"happy": true,
"name": "Niels",
"nothing": null,
"answer": {
"everything": 42
},
"list": [1, 0, 2],
"object": {
"currency": "USD",
"value": 42.99
}
}
)";
std::cout << "Create" << std::endl;
value->as_object()["name"].as_string() = "Alice";
value->as_object()["temperature"] = 25.2;
value->as_object()["unit"] = "celsius";
value->as_object().erase("pi");
auto pos = value->as_object().find("happy");
std::cout << "Happy? : " << pos->value() << std::endl;
const auto clone(*value);
std::cout << (clone == *value) << std::endl;
return 0;
}
int main()
Definition: json_create.cpp:10