Skip to main content

$$jsonpatch

Apply patches defined by JSON Patch RFC-6902

Usage​

{ 
"$$jsonpatch": /* Object to patch */,
"ops": /* array */
}
"$$jsonpatch(<ops>):{input}"

Returns​

Operations output

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryanyYesObject to patch
opsarrayYesA list of operations

JSON Patch Operations​

OperationExample
Add{ "op":"add", "path":"/...", "value":"..." }
Remove{ "op":"remove", "path":"/..." }
Replace{ "op":"replace", "path":"/...", "value":"..." }
Move{ "op":"move", "path":"/...", "from":"/..." }
Copy{ "op":"copy", "path":"/...", "from":"/..." }
Test{ "op":"test", "path":"/...", "value":"..." } (if test fails, the function result will be null)

Examples​

Input

Definition

Output

{
"a": {
"b": "c"
}
}
{
"$$jsonpatch": "$",
"ops": [
{
"op": "add",
"path": "/a/d",
"value": "e"
}
]
}
{
"a": {
"b": "c",
"d": "e"
}
}