9b32f72584
As I learned in https://github.com/melpon/wandbox/issues/209, this library is already installed at Wandbox, so we need to adjust the examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
24 lines
555 B
C++
24 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';
|
|
}
|