Name

cx:json-patch — Applies a patch to a JSON document.

Synopsis

This step applies the provided patch to the source document, returning the patched result.

Input portPrimarySequenceContent types
source✔  json 
patch  json 
Output portPrimarySequenceContent types
result✔  json 
Option nameTypeDefault value
mergexs:booleanfalse()
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="patch" content-types="json"/>
  |   <p:output port="result" content-types="json"/>
5 |   <p:option name="merge" as="xs:boolean" select="false()"/>
  |</p:declare-step>

Description

This step uses the json-patch library version 1.13 to apply the JSON Patch document provided on the patch port to the source document. The resulting patched document is returned.

If merge is false, the patch is used as a JSON Patch (RFC 6902).

If merge is true, the patch is used as a JSON Merge Patch (RFC 7386).

The cx:json-diff step can be used to compute a patch between two JSON documents.

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