Tag: jsonexception

JSON对象无法转换为JSON数组

当我尝试从服务器转换以下JSON响应字符串时,我收到此错误。 我希望处理JSONObject或JSONArray,具体取决于服务器的响应,因为大多数时候它返回JSONArray。 来自服务器的JSON响应 jsonString = {“message”:”No Results found!”,”status”:”false”} Java代码如下 try { JSONArray jsonArrayResponse = new JSONArray(jsonString); if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { if(jsonArrayResponse != null && jsonArrayResponse.length() > 0) { getCancelPurchase(jsonArrayResponse.toString()); } } } catch(JSONException e) { e.printStackTrace(); } 错误日志: org.json.JSONException: Value {“message”:”No Results found!”,”status”:”false”} of type org.json.JSONObject cannot be converted to JSONArray at org.json.JSON.typeMismatch(JSON.java:111) at org.json.JSONArray.(JSONArray.java:96) […]