diff --git a/README.markdown b/README.markdown index 5e2545d0e..7002a18f5 100644 --- a/README.markdown +++ b/README.markdown @@ -6,6 +6,42 @@ standards such as [JSON Schema](http://json-schema.org), [JSON Pointer](https://www.rfc-editor.org/rfc/rfc6901), [JSONL](https://jsonlines.org), and more. +Example + +```cpp +#include +#include +#include +#include + +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" + // } +} +``` + Documentation ------------- @@ -22,3 +58,5 @@ long the outcome is distributed under the same license. Otherwise, you must obtain a [commercial license](./LICENSE-COMMERCIAL) that removes such restrictions. Read more about our licensing approach [here](https://www.sourcemeta.com/licensing/). + +