MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / applyMergeOperation

Function applyMergeOperation

source/core/StarJsonPatch.cpp:182–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180 }
181
182 Json applyMergeOperation(Json const& base, Json const& op) {
183 String path = op.getString("path");
184 auto pointer = JsonPath::Pointer(path);
185
186 if (op.contains("search")) {
187 auto searchable = pointer.get(base);
188 auto searchValue = op.get("search");
189 if (size_t index = findJsonMatch(searchable, searchValue, pointer))
190 return pointer.add(pointer.remove(base), searchable.set(index - 1, jsonMerge(searchable.get(index - 1), op.get("value"))));
191 else
192 return base;
193 } else {
194 return pointer.add(pointer.remove(base), jsonMerge(pointer.get(base), op.get("value")));
195 }
196 }
197}
198
199}

Callers

nothing calls this directly

Calls 9

PointerClass · 0.85
findJsonMatchFunction · 0.85
getStringMethod · 0.80
jsonMergeFunction · 0.70
containsMethod · 0.45
getMethod · 0.45
addMethod · 0.45
removeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected