3 ms·
Thought I'd share something I discovered about Json comparison. This simple line also works: return jsonObject1.toMap().equals(jsonObject2.equals); because
by jermo 8y ago
Thought I'd share something I discovered about Json comparison. This simple line also works:
return jsonObject1.toMap().equals(jsonObject2.equals);
because JsonObject uses HashMap internally which supports equals(). The downside is it would be slower because toMap() creates a copy.
Btw, downloaded java-commons as Maven dependency from JitPack:
https://jitpack.io/#blobcity/java-commons https://jitpack.io/#blobcity/java-commons
- sanketsarang 8y agoYes this also works. We were using this for a while until we landed up with very large JSON's. .toMap() is very expensive and takes significantly longer to execute on large JSON's.