-
Notifications
You must be signed in to change notification settings - Fork 148
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
copy/replace in one patch doc #64
Comments
I noticed in zjsonpatch/src/main/java/com/flipkart/zjsonpatch/InPlaceApplyProcessor.java Lines 53 to 59 in af15e01
Is this a bug? As any mutation done to the source Here's an example:Original document:
Patch:
Result:
Note that both |
@luliu @amarchewka |
That's great. Thanks! |
The bug is fixed, Closing the issue. Thanks again for raising the issue. |
If I start with the following JSON doc:
{"profiles":{"abc":[],"def":[{"hello":"world"}]}}
and apply the following patch:
[{"op":"copy","from":"/profiles/def/0", "path":"/profiles/def/0"},{"op":"replace","path":"/profiles/def/0/hello","value":"world2"}]
I get the following output:
{"profiles":{"abc":[],"def":[{"hello":"world2"},{"hello":"world2"}]}}
That is, the "replace" operation was applied to both array elements.
(Or possibly, the "replace" was applied before the "copy".)
Applying the "copy" and then the "replace" in 2 separate patch docs works as expected.
The following on-line tool [https://json-schema-validator.herokuapp.com/jsonpatch.jsp]
agrees the original output should have been
{"profiles":{"abc":[],"def":[{"hello":"world2"},{"hello":"world"}]}}
with the "replace" applied only to array element 0.
Thanks for a great library, btw!
The text was updated successfully, but these errors were encountered: