31 lines
601 B
Markdown
31 lines
601 B
Markdown
# 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_document.merge_patch(j_patch);
|
|
// {
|
|
// "a": "z",
|
|
// "c": {
|
|
// "d": "e"
|
|
// }
|
|
// }
|
|
```
|