if you want to check for the json empty case, we can directly use below code
String jsonString = {};
JSONObject jsonObject = new JSONObject(jsonString);
if(jsonObject.isEmpty()){
System.out.println("json is empty");
} else{
System.out.println("json is not empty");
}
this may help you.