How to test if JSON object is empty in Java
obj.length() == 0
is what I would do.
If you're okay with a hack -
obj.toString().equals("{}");
Serializing the object is expensive and moreso for large objects, but it's good to understand that JSON is transparent as a string, and therefore looking at the string representation is something you can always do to solve a problem.
If empty array:
.size() == 0
if empty object:
.length() == 0