如下,用 JSONTokener 实现:
Object json = new JSONTokener(stringData).nextValue();if(json instanceof JSONObject){ JSONObject jsonObject = (JSONObject)json; //further actions on jsonObjects //...}else if (json instanceof JSONArray){ JSONArray jsonArray = (JSONArray)json; //further actions on jsonArray //...}