1# basic_json::merge_patch 2 3```cpp 4void merge_patch(const basic_json& apply_patch); 5``` 6 7The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of 8modifications to a target resource's content. This function applies a merge patch to the current JSON value. 9 10The function implements the following algorithm from Section 2 of 11[RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): 12 13```python 14define MergePatch(Target, Patch): 15 if Patch is an Object: 16 if Target is not an Object: 17 Target = {} // Ignore the contents and set it to an empty Object 18 for each Name/Value pair in Patch: 19 if Value is null: 20 if Name exists in Target: 21 remove the Name/Value pair from Target 22 else: 23 Target[Name] = MergePatch(Target[Name], Value) 24 return Target 25 else: 26 return Patch 27``` 28 29Thereby, `Target` is the current object; that is, the patch is applied to the current value. 30 31## Parameters 32 33`apply_patch` (in) 34: the patch to apply 35 36## Complexity 37 38Linear in the lengths of `apply_patch`. 39 40## Example 41 42??? example 43 44 The following code shows how a JSON Merge Patch is applied to a JSON document. 45 46 ```cpp 47 --8<-- "examples/merge_patch.cpp" 48 ``` 49 50 Output: 51 52 ```json 53 --8<-- "examples/merge_patch.output" 54 ``` 55 56## Version history 57 58- Added in version 3.0.0. 59