! @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
| 22579 | @since version 3.0.0 |
| 22580 | */ |
| 22581 | void merge_patch(const basic_json& apply_patch) |
| 22582 | { |
| 22583 | if (apply_patch.is_object()) |
| 22584 | { |
| 22585 | if (not is_object()) |
| 22586 | { |
| 22587 | *this = object(); |
| 22588 | } |
| 22589 | for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) |
| 22590 | { |
| 22591 | if (it.value().is_null()) |
| 22592 | { |
| 22593 | erase(it.key()); |
| 22594 | } |
| 22595 | else |
| 22596 | { |
| 22597 | operator[](it.key()).merge_patch(it.value()); |
| 22598 | } |
| 22599 | } |
| 22600 | } |
| 22601 | else |
| 22602 | { |
| 22603 | *this = apply_patch; |
| 22604 | } |
| 22605 | } |
| 22606 | |
| 22607 | /// @} |
| 22608 | }; |