json/doc/examples/emplace.cpp

24 lines
428 B
C++
Raw Normal View History

#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.emplace("three", 3);
null.emplace("A", "a");
null.emplace("B", "b");
// print values
std::cout << object << '\n';
std::cout << null << '\n';
}