Skip to main content

json-patch

Latest Versionv1.0.0
Input Content Typeapplication/json
Output Content Typeapplication/json

The json-patch transformer applies the provided patch to the data message payload. The patch must be a valid RFC 6902 JSON patch document. Supported operations include:

  • add
  • remove
  • replace
  • copy
  • move
  • test

Patches that specify a remove operation on non-existent fields will be applied successfully with the remove operation ignored. Patches that specify an add operation on a non-existent nested field will have the nested object structure automatically injected into the payload.

Example Usage

    transformer:
type: json-patch
version: v1
parameters:
patch: |
[
{ "op": "replace", "path": "/temp", "value": 23.6847 },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/lat" }
]

Example Input

Path: /sensor0

{
"temp": 55.8324,
"lat": 51.9977,
"long": 0.7407
}

Example Output

Path: /sensor0

{
"temp": 23.6847,
"long": 0.7407,
"hello": ["world"]
}