circe/circe

Json diff

agourlay opened this issue ยท 7 comments

It would be really handy for debugging and error reporting to have the possibility to compute the difference between two Json values.

I would love to migrate to Circe but I need this feature, therefore I am still using Json4s which has a diff API returning:
Diff(changed: JValue, added: JValue, deleted: JValue) see implementation here

Maybe there is already a way of achieving this easily?

Thank you for this nice library.

I've been meaning to provide something similar to this powered by delta, which already includes a module for Argonaut that should be fairly straightforward to adapt for circe.

It doesn't provide exactly the same kind of diff as Json4s, though, but it has support for both JSON Patch and a compressed representation, and I'd guess it shouldn't be too hard to adapt one of those formats to do what you need.

Just wanted to share for the people interested in this feature that I was able to port the Json4s implementation to Circe.

It is not super good looking and does a bunch of ugly Option.get but it seems like it gets the job done.

Check this PR for some code.

There's https://github.com/gnieh/diffson which will support circe very soon.

Support for circe was just merged. Version 2.1.0 with this support will be released next week.

diffjson looks great, I will definitely try it ๐Ÿ‘

Coming back to you guys with some update.
I have been using successfully diffson as alternative and it is working great for me so far.

From my perspective this issue can be closed from the time being.
Thanks @satabin for the sweet lib ๐Ÿ‘

Glad it helps. Do not hesitate to report bugs or ask for enhancements if you find anything.