Skip to main content

$$jsonpatch

Apply patches defined by JSON Patch RFC-6902

Usage​

{
"$$jsonpatch": /* value */,
"ops": [ /* JSON Patch operations */ ]
}
"$$jsonpatch(<ops>):{input}"

Returns​

Depends on the expression

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryanyYesObject to patch
opsarrayOperations as defined in RFC-6902 (see below)YesA 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"
}
}