📝 documented JSON Merge Patch (RFC 7386)
This commit is contained in:
parent
102c474397
commit
e95578f884
1 changed files with 32 additions and 0 deletions
32
README.md
32
README.md
|
@ -21,6 +21,7 @@
|
||||||
- [STL-like access](#stl-like-access)
|
- [STL-like access](#stl-like-access)
|
||||||
- [Conversion from STL containers](#conversion-from-stl-containers)
|
- [Conversion from STL containers](#conversion-from-stl-containers)
|
||||||
- [JSON Pointer and JSON Patch](#json-pointer-and-json-patch)
|
- [JSON Pointer and JSON Patch](#json-pointer-and-json-patch)
|
||||||
|
- [JSON Merge Patch](#json-merge-patch)
|
||||||
- [Implicit conversions](#implicit-conversions)
|
- [Implicit conversions](#implicit-conversions)
|
||||||
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
|
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
|
||||||
- [Binary formats (CBOR, MessagePack, and UBJSON)](#binary-formats-cbor-messagepack-and-ubjson)
|
- [Binary formats (CBOR, MessagePack, and UBJSON)](#binary-formats-cbor-messagepack-and-ubjson)
|
||||||
|
@ -456,6 +457,37 @@ json::diff(j_result, j_original);
|
||||||
// ]
|
// ]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### JSON Merge Patch
|
||||||
|
|
||||||
|
The library supports **JSON Merge Patch** ([RFC 7386](https://tools.ietf.org/html/rfc7386)) as a patch format. Instead of using JSON Pointer (see above) to specify values to be manipulated, it describes the changes using a syntax that closely mimics the document being modified.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// a JSON value
|
||||||
|
json j_document = R"({
|
||||||
|
"a": "b",
|
||||||
|
"c": {
|
||||||
|
"d": "e",
|
||||||
|
"f": "g"
|
||||||
|
}
|
||||||
|
})"_json;
|
||||||
|
|
||||||
|
// a patch
|
||||||
|
json j_patch = R"({
|
||||||
|
"a":"z",
|
||||||
|
"c": {
|
||||||
|
"f": null
|
||||||
|
}
|
||||||
|
})"_json;
|
||||||
|
|
||||||
|
// apply the patch
|
||||||
|
j_original.merge_patch(j_patch);
|
||||||
|
// {
|
||||||
|
// "a": "z",
|
||||||
|
// "c": {
|
||||||
|
// "d": "e"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
```
|
||||||
|
|
||||||
### Implicit conversions
|
### Implicit conversions
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue