Add example
This commit is contained in:
parent
22f7368574
commit
d06a9f8809
13
docs/examples/operator_ltlt__json_pointer.cpp
Normal file
13
docs/examples/operator_ltlt__json_pointer.cpp
Normal 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;
|
||||||
|
}
|
||||||
1
docs/examples/operator_ltlt__json_pointer.output
Normal file
1
docs/examples/operator_ltlt__json_pointer.output
Normal file
@ -0,0 +1 @@
|
|||||||
|
/foo/bar/baz
|
||||||
@ -55,7 +55,7 @@ Linear.
|
|||||||
??? example "Example: (1) serialize JSON value to stream"
|
??? example "Example: (1) serialize JSON value to stream"
|
||||||
|
|
||||||
The example below shows the serialization with different parameters to `width` to adjust the indentation level.
|
The example below shows the serialization with different parameters to `width` to adjust the indentation level.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
--8<-- "examples/operator_ltlt__basic_json.cpp"
|
--8<-- "examples/operator_ltlt__basic_json.cpp"
|
||||||
```
|
```
|
||||||
@ -66,6 +66,19 @@ Linear.
|
|||||||
--8<-- "examples/operator_ltlt__basic_json.output"
|
--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
|
## Version history
|
||||||
|
|
||||||
1. Added in version 1.0.0. Added support for indentation character and deprecated
|
1. Added in version 1.0.0. Added support for indentation character and deprecated
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user