Dominik Meyer
cc002ebfbb
git-subtree-dir: libs/json git-subtree-split: f42a74b8f53cc308647123d49d33d1c8122e3f42
26 lines
584 B
C++
26 lines
584 B
C++
#include <iostream>
|
|
#include <nlohmann/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';
|
|
}
|