MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / merge_patch

Function merge_patch

Source/Utils/json.hpp:25132–25156  ·  view source on GitHub ↗

! @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

Source from the content-addressed store, hash-verified

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 };

Callers

nothing calls this directly

Calls 6

is_objectFunction · 0.85
eraseFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected