JSON Toolkit is a swiss-army knife for JSON programming in modern C++. It comes with a built-in parser and growing support for standards such as JSON Schema, JSON Pointer, JSONL, and more.
Example
#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonpointer.h>
#include <sstream>
#include <iostream>
int main() {
// Creating JSON using parse
sourcemeta::jsontoolkit::JSON document =
sourcemeta::jsontoolkit::parse(R"JSON({
"name": "John Doe",
"age": 20,
"address": "zxy"
})JSON");
// JSON pointer for the name property
const sourcemeta::jsontoolkit::Pointer name_pointer{"name"};
// A new JSON document for the name
const sourcemeta::jsontoolkit::JSON name_value{"Johnny Doe"};
// Updating the value of the name using JSON pointer
sourcemeta::jsontoolkit::set(document, name_pointer, name_value);
sourcemeta::jsontoolkit::prettify(document, std::cout);
std::cout<<"\n";
// The above program will print the following to standard output:
//output :
// {
// "address": "zxy_with_bar",
// "age": 21,
// "name": "xyz_with_foo"
// }
}
Refer to the project website for documentation: https://jsontoolkit.sourcemeta.com.
This project is governed by the AGPL-3.0 copyleft license and our Contribution Agreement. To ensure the sustainability of the project, you can freely make use of this software as long the outcome is distributed under the same license. Otherwise, you must obtain a commercial license that removes such restrictions. Read more about our licensing approach here.