You can use ObjctMapper and convert your Json's to string to find the differences,
ObjectMapper mapper = new ObjectMapper();
TypeReference<HashMap<String, Object>> type =
new TypeReference<HashMap<String, Object>>() {};
Map<String, Object> firstJsonMap = mapper.readValue(firstJsonElement, type);
Map<String, Object> secondJsonMap = mapper.readValue(secondJsonElement, type);
MapDifference<String, Object> difference = Maps.difference(firstJsonMap, secondJsonMap);
If you wish to get flat the extracted difference map for getting more meaningful result see here .
On the second way you can use JsonNode to finding the difference as follow (below example is just checking if they are same or not indeed)
JsonNode actualObj1 = mapper.readTree("your firstJson string");
JsonNode actualObj2 = mapper.readTree("your secondJson string");
TextNodeComparator cmp = new TextNodeComparator();
public class TextNodeComparator implements Comparator<JsonNode>
{
@Override
public int compare(JsonNode o1, JsonNode o2) {
if (o1.equals(o2)) {
return 0;
}
if ((o1 instanceof TextNode) && (o2 instanceof TextNode)) {
String s1 = ((TextNode) o1).asText();
String s2 = ((TextNode) o2).asText();
if (s1.equalsIgnoreCase(s2)) {
return 0;
}
}
return 1;
}
}