How to check if JSON object is empty in Java?
Question
In Java, if I use the following JSON
string as an example, how would I check if the objects are empty/null?
{"null_object_1" : [], "null_object_2" : [null] }
I have tried using:
if(!jsonSource.isNull("null_object_1")) {/*null_object_1 is not empty/null*/}
if(!jsonSource.isNull("null_object_2")) {/*null_object_2 is not empty/null*/}
But these IF
statements still return true (as if they are not empty/null).
Does anyone have a solution?
Edit:
By "object", I actually meant array
.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow