T
T
Tatyana2015-07-20 11:18:19
Java
Tatyana, 2015-07-20 11:18:19

How to compare two json for matching, extra and missing elements? Ideally in groovy or java?

How to compare two jasons like
[{id:5, color:red}, {id:8, color:blue}{id:9, color:blue}{id:2, color:green}] and {[id: 2, status:1], [id:8, status:2],[id:100, status:1]}
I expect something like this:
Matches 2 elements, with id=2 and id=8.
Elements not found: id = 5, id = 9
Missing elements: id:100.
That is, I need the complete difference between two json objects by id, while there is no sorting by id, and each element has other parameters besides id (which may differ).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question