-
Notifications
You must be signed in to change notification settings - Fork 147
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
Unexpected result while applying copy operation #125
Comments
I think this function only solved 'array index out of bound' exception although number comparison is fixed. There still exists array index disalignment problem when element is removed from array before copy operation applied. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As the original source and target json file size is too big, here I just describe the problem because the bug is explicit.
The generated copy operation is {"op": "copy", "from": "/data/109/id", "path": "/data/75/id"} which would cause wrong copied value when one or more item of 'data' array has been removed. For example, when /data/50 was removed by remove operation before copy, then /data/75/id will actually get the value from /data/110/id rather than /data/109/id.
I noticed you have already come across similar problem and provided JsonDiff.isAllowed() function(attached below) to try to solve it. But there exists an bug in the function. when both srcStr and dstStr are numeric, we should compare their number value rather than string value. 109 > 75, but "109" < "75" which cause JsonDiff.isAllowed(JsonPointer.parse("/data/109/id"), JsonPointer.parse("/data/75/id")) passed this function.
Specifications
Java 1.8 zjsonpatch 0.4.11
The text was updated successfully, but these errors were encountered: