Can not run "add" on root object
Closed this issue · 0 comments
randmonkey commented
If I create a JSON patch to run "add" on root path like this:
[
{"op":"add","path":"","value":{"foo":"bar"}}
]
It could not set the entire document to {"foo":"bar"}
as expected.
According to https://datatracker.ietf.org/doc/html/rfc6902#section-4.1, the add
op MUST set the entire content of target document to the specified value. While actually:
- If the original document is empty (empty raw JSON), the result is also empty
- If the original document has any content (empty array
[]
, empty object{}
, non-empty array["a","b"]
or non-empty object{"k":"v"}
), the applying will return erroradd operation does not apply: doc is missing path: "": missing value
.