JsonDiff instead; this
class is scheduled for removal in 1.3@Deprecated public final class JsonDiff extends Object
This class only has one method, asJson(JsonNode, JsonNode), which
takes two JSON values as arguments and returns a patch as a JsonNode.
This generated patch can then be used in JsonPatch.fromJson(JsonNode).
Numeric equivalence is respected. When dealing with container values (ie, objects or arrays), operations are always generated in the following order:
Note that due to the way JsonNode is implemented, this class is
inherently not thread safe (since JsonNode is mutable). It is
therefore the responsibility of the caller to ensure that the calling context
is safe (by ensuring, for instance, that only the diff operation has
references to the values to be diff'ed).
Note also that currently, no effort is made to "factorize" operations. That is, generating the patch for the following two nodes:
{ "a": "b" } (first),{ "c": "b" } (second)will generate:
[
{ "op": "add": "path": "/c", "value": "b" },
{ "op": "remove", "path": "/a" }
]
even though a shorter version would be:
[ { "op": "move": "from": "/a", "path": "/c" } ]
Copyright © 2013. All Rights Reserved.