@ParametersAreNonnullByDefault public abstract class JsonMergePatch extends Object implements JsonSerializable
JSON Merge Patch is a "toned down" version of JSON Patch. However, it covers a very large number of use cases for JSON value modifications; its focus is mostly on patching JSON Objects, which are by far the most common type of JSON texts exchanged on the Internet.
Applying a JSON Merge Patch is defined by a single, pseudo code function as follows (quoted from the RFC; indentation fixed):
define MergePatch(Target, Patch):
if Patch is an Object:
if Target is not an Object:
Target = {} # Ignore the contents and set it to an empty Object
for each Name/Value pair in Patch:
if Value is null:
if Name exists in Target:
remove the Name/Value pair from Target
else:
Target[Name] = MergePatch(Target[Name], Value)
return Target
else:
return Patch
| Modifier and Type | Field and Description |
|---|---|
protected static MessageBundle |
BUNDLE |
| Constructor and Description |
|---|
JsonMergePatch() |
| Modifier and Type | Method and Description |
|---|---|
abstract JsonNode |
apply(JsonNode input)
Apply the patch to a given JSON value
|
static JsonMergePatch |
fromJson(JsonNode node)
Build an instance from a JSON input
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitserialize, serializeWithTypeprotected static final MessageBundle BUNDLE
public static JsonMergePatch fromJson(JsonNode node) throws JsonPatchException
node - the inputJsonPatchException - failed to deserializeNullPointerException - node is nullpublic abstract JsonNode apply(JsonNode input) throws JsonPatchException
input - the value to patchJsonPatchException - never thrown; only for consistency with
JsonPatchNullPointerException - value is null