public interface JsonMergePatch
This interface represents an implementation of a JSON Merge Patch as defined by RFC 7396.
A JsonMergePatch
can be instantiated with Json.createMergePatch(JsonValue)
by specifying the patch operations in a JSON Merge Patch or using Json.createMergeDiff(JsonValue, JsonValue)
to create a JSON Merge Patch based on the difference between two JsonValue
s.
1. Construct a JsonMergePatch with an existing JSON Merge Patch.
JsonValue contacts = ... ; // The target to be patched
JsonValue patch = ... ; // JSON Merge Patch
JsonMergePatch mergePatch = Json.createMergePatch(patch);
JsonValue result = mergePatch.apply(contacts);
2. Construct a JsonMergePatch from a difference between two JsonValue
s.
JsonValue source = ... ; // The source object
JsonValue target = ... ; // The modified object
JsonMergePatch mergePatch = Json.createMergeDiff(source, target); // The diff between source and target in a Json Merge Patch format
Modifier and Type | Method and Description |
---|---|
JsonValue |
apply(JsonValue target)
Applies the JSON Merge Patch to the specified
target . |
JsonValue |
toJsonValue()
Returns the
JsonMergePatch as JsonValue . |
JsonValue apply(JsonValue target)
target
.
The target is not modified by the patch.target
- the target to apply the merge patchJsonValue toJsonValue()
JsonMergePatch
as JsonValue
.JsonMergePatch
as JsonValue
Copyright © 1996-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.