Sha256: 92a00f1b2fe6c81fc5741b82b83ad30c40ea7bf2715281f6a42f12f9cf1e0fed

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

#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({"three", 3});  // object is extended
    object += {"four", 4};           // object is extended
    null.push_back({"five", 5});     // null is converted to array

    // print values
    std::cout << object << '\n';
    std::cout << null << '\n';

    // would throw:
    //object.push_back({1, 2, 3});
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simdjson-0.3.0 vendor/simdjson/dependencies/json/doc/examples/push_back__initializer_list.cpp