Add example

This commit is contained in:
Florian Albrechtskirchinger 2022-07-23 19:34:47 +02:00
parent 22f7368574
commit d06a9f8809
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,13 @@
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON poiner
json::json_pointer ptr("/foo/bar/baz");
// write string representation to stream
std::cout << ptr << std::endl;
}

View File

@ -0,0 +1 @@
/foo/bar/baz

View File

@ -55,7 +55,7 @@ Linear.
??? example "Example: (1) serialize JSON value to stream"
The example below shows the serialization with different parameters to `width` to adjust the indentation level.
```cpp
--8<-- "examples/operator_ltlt__basic_json.cpp"
```
@ -66,6 +66,19 @@ Linear.
--8<-- "examples/operator_ltlt__basic_json.output"
```
??? example "Example: (2) write JSON pointer to stream"
The example below shows how to write a JSON pointer to a stream.
```cpp
--8<-- "examples/operator_ltlt__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/operator_ltlt__json_pointer.output"
```
## Version history
1. Added in version 1.0.0. Added support for indentation character and deprecated