diffson icon indicating copy to clipboard operation
diffson copied to clipboard

Difference between two Jsons

Open ghost opened this issue 5 years ago • 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.

ghost avatar Mar 04 '20 17:03 ghost

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?

satabin avatar Mar 05 '20 15:03 satabin

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.

ghost avatar Mar 13 '20 16:03 ghost

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.

satabin avatar Mar 14 '20 10:03 satabin

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

ghost avatar Mar 15 '20 20:03 ghost