! @brief applies a JSON Merge Patch The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of modifications to a target resource's content. This function applies a merge patch to the current JSON value. The function implements the following algorithm from Section 2 of [RFC 7396 (JSON Merge Patch)](https://tools.i
| 8928 | @since version 3.0.0 |
| 8929 | */ |
| 8930 | void merge_patch(const basic_json& apply_patch) |
| 8931 | { |
| 8932 | if (apply_patch.is_object()) |
| 8933 | { |
| 8934 | if (!is_object()) |
| 8935 | { |
| 8936 | *this = object(); |
| 8937 | } |
| 8938 | for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) |
| 8939 | { |
| 8940 | if (it.value().is_null()) |
| 8941 | { |
| 8942 | erase(it.key()); |
| 8943 | } |
| 8944 | else |
| 8945 | { |
| 8946 | operator[](it.key()).merge_patch(it.value()); |
| 8947 | } |
| 8948 | } |
| 8949 | } |
| 8950 | else |
| 8951 | { |
| 8952 | *this = apply_patch; |
| 8953 | } |
| 8954 | } |
| 8955 | |
| 8956 | /// @} |
| 8957 | }; |