Sha256: db7126a44c39800d963e9458341bb73e706609253bbd80668f409796489af260

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

int main()
{
    // create a JSON object
    json object =
    {
        {"one", 1}, {"two", 2}, {"three", 2.9}
    };

    // output element with key "two"
    std::cout << object["two"] << "\n\n";

    // change element with key "three"
    object["three"] = 3;

    // output changed array
    std::cout << std::setw(4) << object << "\n\n";

    // mention nonexisting key
    object["four"];

    // write to nonexisting key
    object["five"]["really"]["nested"] = true;

    // output changed object
    std::cout << std::setw(4) << object << '\n';
}

Version data entries

1 entries across 1 versions & 1 rubygems

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