ajv-merge-patch icon indicating copy to clipboard operation
ajv-merge-patch copied to clipboard

$patch remove keyword from required

Open mostafahatem20 opened this issue 3 years ago • 1 comments

I saw in the tests how to add an attribute to the required keyword { "op": "add", "path": "/required/-", "value": "q" } but I want to ask how can i remove a keyword from being required I tried { "op": "remove", "path": "/required/-q"} but it did not work i seem to get it wrong so if anyone can help I would be grateful. Thank you

mostafahatem20 avatar Apr 24 '21 14:04 mostafahatem20

Value-based array operations are not supported yet in JSON patch. See this issue: https://github.com/json-patch/json-patch2/issues/18 You need to remove values in an array based on index.

An example target JSON document:

   { "foo": [ "bar", "qux", "baz" ] }

A JSON Patch document:

   [
     { "op": "remove", "path": "/foo/1" }
   ]

The resulting JSON document:

   { "foo": [ "bar", "baz" ] }

pieterjandesmedt avatar Apr 28 '21 08:04 pieterjandesmedt