J++Jsonic++
Getting started

Drop in json.h.

Jsonic++ is header-only. Vendor include/json.h into your project, compile as C++17 or later, and you have the complete parser, value model and serializer—there is no library to build or runtime dependency to ship.

Your first parse

#include "json.h"
#include <iostream>

int main() {
    json::Document value;
    std::string error;

    const std::string source =
        R"({"name":"Jsonic++","ready":true})";

    if (!json::Document::parse(
            source, value, error)) {
        std::cerr << error << "\n";
        return 1;
    }

    std::cout << value["name"].string << "\n";
    std::cout << std::boolalpha << value["ready"].boolean << "\n";
}

Document::parse() returns true on success. On failure it returns false and fills the supplied error string with a message plus line and column information. Parsing never requires exceptions in the ordinary success/failure path.

Inspect before you read

A json::Document can represent null, boolean, number, string, array or object. The is_*() helpers make type checks explicit; the public payload fields then expose ordinary C++ data.

if (value.has("name") && value["name"].is_string()) {
    const std::string& name = value["name"].string;
}

if (value.has("items") && value["items"].is_array()) {
    for (const auto& item : value["items"].array) {
        // item is another json::Document
    }
}

Construct and serialize

You can also build documents directly. Null values promote to objects when indexed by key and to arrays when passed to push_back(), which keeps small construction code compact without hiding the resulting type.

json::Document response = json::Document::make_object();
response["ok"] = true;
response["message"] = "done";
response["items"] = json::Document::make_array();
response["items"].push_back(1);
response["items"].push_back(2);

std::string pretty = response.dump(2);
std::string compact = response.dump(0);

Integrate it your way

The repository does not force CMake, pkg-config, generated code or a package-specific build model. Copy the header into a vendor/include directory, add that directory to your compiler include path, and keep ownership of the surrounding project. If you prefer to track Jsonic++ as a Git dependency, submodule or package recipe, the library shape does not change.

Build the repository tests

make test
make test-sanitize

The standalone tests are only one layer. Jsonic++ is the canonical owner of the header; parser changes are synchronized into Nift and Minify++ and must pass exact-copy checks plus those consumers' integration contracts. Continue with the API reference for every public operation, or Contracts for the behavioral guarantees behind the implementation.