idubrov / json-patch

RFC 6902 (JSON Patch) / RFC 7396 (JSON Merge Patch) implementation for Rust
Apache License 2.0
127 stars 17 forks source link

diff() can produce ops in the wrong order #6

Closed asayers closed 5 years ago

asayers commented 5 years ago

There are two possible patches which will take you from [1,2] to []:

[{"op":"remove","path":"/1"},{"op":"remove","path":"/0"}]
[{"op":"remove","path":"/0"},{"op":"remove","path":"/0"}]

The diff() function gives the following (invalid) patch:

[{"op":"remove","path":"/0"},{"op":"remove","path":"/1"}]
idubrov commented 5 years ago

🙀

idubrov commented 5 years ago

Fixed in 0.2.4. Fix is a bit sketchy, but seems to work 😁

asayers commented 5 years ago

Thanks!