Name

cx:json-diff — Find the differences between two JSON documents.

Synopsis

This step compares two JSON documents and describes the differences between them.

Input portPrimarySequenceContent types
source✔  json 
target  json 
Output portPrimarySequenceContent types
result✔  json 
This is an extension step; to use it, your pipeline must include its declaration. For example, by including the extension library with an import at the top of your pipeline:
<p:import href="https://xmlcalabash.com/ext/library/json-patch.xpl"/>
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
  |   <p:input port="source" content-types="json" primary="true"/>
  |   <p:input port="target" content-types="json"/>
  |   <p:output port="result" content-types="json"/>
5 |</p:declare-step>

Description

This step uses the json-patch library version 1.13 to find the difference between two JSON documents. The result is a JSON document that describes differences in a JSON Patch (RFC 6902).

The resulting patch can be applied with cx:json-patch to convert the source into the target.

Dependencies

This step is included in the XML Calabash application. If you are getting XML Calabash from Maven, you will also need to include the extension dependency:

  • com.github.java-json-tools:json-patch:1.13