Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not run "add" on root object #188

Closed
randmonkey opened this issue Nov 16, 2023 · 0 comments
Closed

Can not run "add" on root object #188

randmonkey opened this issue Nov 16, 2023 · 0 comments

Comments

@randmonkey
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant