$$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​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | any | Yes | Object to patch | |
ops | array | Operations as defined in RFC-6902 (see below) | Yes | A list of operations |
JSON Patch Operations​
Operation | Example |
---|---|
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"
}
}