Is there any Java library that shows diff of two Json files. I am aware of Zjsonpatch , DiffSon and json-patch java library, but is there any other library that performs the diff and which is the recommended one.
1 Answer
If you can parse the JSON to a Map, you can use Guava's Maps.difference() to generate a diff.
3 Comments
pjain
I am looking for some java library that can give output in pretty print format in Console, something like jsondiff.com
pjain
That's a great solution. Thanks!! But how to handle cases where I have nested json like {x:y, a:{b:1, c:2}} Here, how to compare value of a, i.e. a:{b:1, c:2}
Ivan Balashov
@shmosel Parsing this JSON to a Map
["a", "b"] fails.