You can check whether the json has values inside it;
String jsonString= "{ ... }";
Object json = new JSONTokener(jsonString).nextValue();
if (json instanceof JSONObject){
//do operations related with object
}
else if (json instanceof JSONArray) {
//do operations based on an array
}