Arrays should have value-based patch operations. Currently, only index-based actions are permitted:
- insert by index or last;
- replace by index;
- remove by index.
The current spec lacks value-based operations on arrays, such as:
- insert before/after certain existing values;
- replace existing values;
- remove by values.
For example, given:
{
"items": [ "a", "c", "e", "z" ]
}
This patch should be valid:
[
{ "op": "add", "path": "/items/-", "value": "b", "before": "c" },
{ "op": "replace", "path": "/items/-", "value": "d", "replace": "e" },
{ "op": "remove", "path": "/items/-", "value": "z" }
]
And produce:
{
"items": [ "a", "b", "c", "d" ]
}
The special - key, could be the indicator of an array at a specific path to keep compatibility with the current spec.
Arrays should have value-based patch operations. Currently, only index-based actions are permitted:
The current spec lacks value-based operations on arrays, such as:
For example, given:
{ "items": [ "a", "c", "e", "z" ] }This patch should be valid:
[ { "op": "add", "path": "/items/-", "value": "b", "before": "c" }, { "op": "replace", "path": "/items/-", "value": "d", "replace": "e" }, { "op": "remove", "path": "/items/-", "value": "z" } ]And produce:
{ "items": [ "a", "b", "c", "d" ] }The special
-key, could be the indicator of an array at a specific path to keep compatibility with the current spec.