Determine whether the string is JSONObject or JSONArray?

Object json = new JSONTokener(jsonResponse).nextValue();
if (json instanceof JSONObject) {
    JSONObject jsonObject = (JSONObject) json;

} else if (json instanceof JSONArray){
    JSONArray jsonArray = (JSONArray) json;
    

Guess you like

Origin blog.csdn.net/jiabaokang/article/details/75579008