1
0
mirror of https://github.com/nlohmann/json synced 2024-11-30 15:40:07 +00:00
nlohmannjson/doc/examples/push_back__object_t__value.cpp
2016-01-30 20:23:14 +01:00

25 lines
555 B
C++

#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json object = {{"one", 1}, {"two", 2}};
json null;
// print values
std::cout << object << '\n';
std::cout << null << '\n';
// add values
object.push_back(json::object_t::value_type("three", 3));
object += json::object_t::value_type("four", 4);
null += json::object_t::value_type("A", "a");
null += json::object_t::value_type("B", "b");
// print values
std::cout << object << '\n';
std::cout << null << '\n';
}