Javadoc
Compares two json documents and builds an list of all changes
Json containers (objects and arrays) are compared recursively. The comparison
algorithm works like this:
Objects: A field-by-field comparison is done. If a field exists in the first
document but not in the second, that field is removed. If a field exists in
the second document but not the first, that field is added. If a field exists
in both documents with different values, that field is modified.
Arrays: There are two possible algorithms to compare arrays. If array
elements contain a unique identifier (which is defined by the caller), then
array elelements of the first and the second document are matched using the
unique identifiers of array elements. Then each matching array element is
compared to generate the detailed difference. If array elements don't have
unique identifiers, then each element of the first array is compared to each
element of the second array, and the elements with minimal number of changes
are associated. Elements that are too different from each other are not
associated.
Differences:
An Addition denotes a new field or array element. Addition.field1 is null,
meaning the field does not exist in document1, and Addition.field2 denotes
the new field, or array element.
A Removal denotes a removed field or array element. Removal.field1 denotes
the element in document1, and Removal.field2 is null.
A Modification denotes a content modification of a field, or array element.
Both field1 and field2 are non-null, and set to the name of the modified
field.
A Move denotes an array element move. field1 denotes the old index of the
array element, and field2 denotes the new index.
If new elements are added to an array, or existing elements are removed, the
addition and removal appear as diff, and any node that shifted during the
operation appears within a Move.