I'm having preformance issues while comparing two JSONObjects
. My current method of comparison is as followed:
return o1.toString().equals(o2.toString())
However, this is slow. I can't seem to find any other way to properly compare two JSONObjects though. o1.hashCode()
and o2.hashCode()
can be different, while the string is the same. Going through every element and comparing those individually seems tediously slow as well.
Is there any way to compare two JSONObjects faster?
This question is specifically about the use of org.json as supplied by http://json.org/. I really want to refrain from using any other libraries like the ones mentioned in Compare two JSON objects in Java, as this library is critical to some parts of the application.