! @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 M
| 25130 | @since version 3.0.0 |
| 25131 | */ |
| 25132 | void merge_patch(const basic_json& apply_patch) |
| 25133 | { |
| 25134 | if (apply_patch.is_object()) |
| 25135 | { |
| 25136 | if (!is_object()) |
| 25137 | { |
| 25138 | *this = object(); |
| 25139 | } |
| 25140 | for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) |
| 25141 | { |
| 25142 | if (it.value().is_null()) |
| 25143 | { |
| 25144 | erase(it.key()); |
| 25145 | } |
| 25146 | else |
| 25147 | { |
| 25148 | operator[](it.key()).merge_patch(it.value()); |
| 25149 | } |
| 25150 | } |
| 25151 | } |
| 25152 | else |
| 25153 | { |
| 25154 | *this = apply_patch; |
| 25155 | } |
| 25156 | } |
| 25157 | |
| 25158 | /// @} |
| 25159 | }; |