DeltaJSON compares two RFC 7159 conformant JSON files, an A document and a B document, and generates a JSON file representing the differences between the two documents. The document representing the differences is known as a JSON delta file.
Specified object members (name/value pairs) can be ignored (these are removed from the input documents and do not appear in the delta file) and these are specified by name.
The DeltaJSON software is accessed via a REST interface. The software that implements the REST interface requires a Java 8 JRE or JDK runtime of version 1.8.0_102 or later.
DeltaJSON by default generates a delta file.
DeltaJSON can output a merge of two JSON documents such that all of the content of both documents is in the merged result except where two corresponding items differ and in this situation priority is given to either the A or the B document as specified by the user. Strings can be merged as a whole or on a word by word basis.
DeltaJSON can also output a standard JSON Patch file that conforms to RFC 6902 and when applied to the A document will update it to a new document that is equal to the B document (or vice versa but in one direction only according to the direction of patch specified in the procedure call).
Graft or 'Smart Patch'
The full context delta file from DeltaJSON can also be applied as a graft or smart patch operation to apply the changes that are represented in the delta file to a different JSON document (the target document). Changes that are relevant to the target document are applied and any other changes are ignored. This behaviour is similar to the JSON Patch but far more versatile in that the target for a JSON Patch is restricted to the A document but the JSON Graft can be applied to any document.
JSON Delta File
The delta file represents either all the changes in context of the original documents (a "full context" delta).
The JSON delta file contains some header information about the delta and a representation of all the differences (except any that are ignored) between the two input documents. Each change is represented as JSON data.
If the two JSON documents are equal the delta file contains "dx_data_sets": "A=B"
The full context delta contains all the the data from both documents as well as the differences and therefore either document can be extracted from the full context delta.
Changes to strings can be shown either as a complete string replacement or on a word by word basis.
Numbers are normalised prior to comparison so no change would be shown, for example, between '1' and '1.00'.
Array elements are aligned according to their position in the array, or using a best match algorithm or independent of the order of the array elements.
Objects members are aligned on the basis of the string equality of the member name independent of the order of these within the object.