1

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 1

1

If you can parse the JSON to a Map, you can use Guava's Maps.difference() to generate a diff.

Sign up to request clarification or add additional context in comments.

3 Comments

I am looking for some java library that can give output in pretty print format in Console, something like jsondiff.com
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}
@shmosel Parsing this JSON to a Map ["a", "b"] fails.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.