! @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
| 25214 | @since version 3.0.0 |
| 25215 | */ |
| 25216 | void merge_patch(const basic_json& apply_patch) |
| 25217 | { |
| 25218 | if (apply_patch.is_object()) |
| 25219 | { |
| 25220 | if (!is_object()) |
| 25221 | { |
| 25222 | *this = object(); |
| 25223 | } |
| 25224 | for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) |
| 25225 | { |
| 25226 | if (it.value().is_null()) |
| 25227 | { |
| 25228 | erase(it.key()); |
| 25229 | } |
| 25230 | else |
| 25231 | { |
| 25232 | operator[](it.key()).merge_patch(it.value()); |
| 25233 | } |
| 25234 | } |
| 25235 | } |
| 25236 | else |
| 25237 | { |
| 25238 | *this = apply_patch; |
| 25239 | } |
| 25240 | } |
| 25241 | |
| 25242 | /// @} |
| 25243 | }; |