@ParametersAreNonnullByDefault public final class JsonDiff extends Object
This class generates a JSON Patch (as in, an RFC 6902 JSON Patch) given
two JSON values as inputs. The patch can be obtained directly as a JsonPatch or as a JsonNode.
Note: there is no guarantee about the usability of the generated patch for any other source/target combination than the one used to generate the patch.
This class always performs operations in the following order: removals,
additions and replacements. It then factors removal/addition pairs into
move operations, or copy operations if a common element exists, at the same
pointer, in both the source and destination.
You can obtain a diff either as a JsonPatch directly or, for
backwards compatibility, as a JsonNode.
| Modifier and Type | Method and Description |
|---|---|
static JsonNode |
asJson(JsonNode source,
JsonNode target)
Generate a JSON patch for transforming the source node into the target
node
|
static JsonPatch |
asJsonPatch(JsonNode source,
JsonNode target)
Generate a JSON patch for transforming the source node into the target
node
|
public static JsonPatch asJsonPatch(JsonNode source, JsonNode target)
source - the node to be patchedtarget - the expected result after applying the patchJsonPatch