gnieh/diffson

Difference between two Jsons

Closed this issue · 4 comments

Hi! Is diffson capable of calculating the difference between two matching keys. For example
Map("familyAges" -> Map("brother" -> 15))

Map("familyAges" -> Map("brother" -> 16)

The difference of brother in the two JSONs are 1.

The supported patch formats do not allow for this, so currently no. You can always define your own diff algorithm with custom patch format that supports this. It is a quite specific use-case, do you use a completely custom patch format?

Currently, my schema is based on getting the Replace paths that diffson outputs and then traversing the JSON based on that path to get the individual values using circe.

Well, none of the two standard patch formats supported by diffson out of the box can express this kind of diffs. You can always define you own patch format and the associated diff algorithm. Are you only interested in numerical differences? If yes, then diffing is quite easy to implement. If you need more complex diffs, then it can become tricky.

Yes, only numerical diffs. What do you mean by patch format? And how can I define my own. Thanks