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 error add operation does not apply: doc is missing path: "": missing value.
If I create a JSON patch to run "add" on root path like this:
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
addop MUST set the entire content of target document to the specified value. While actually:[], 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.