解析PHP脚本中的JSONArray数据异常



我在下面的Android中收到了错误消息,它是由PHP服务器发送的,简化为JSON数组:

03-20 15:19:17.479: D/requestWorldRecords()(353): org.json.JSONException: Value {"Error":"No Result!"} of type org.json.JSONObject cannot be converted to JSONArray

PHP脚本如下:

$data = array('Error' => "No Result!");  
print_r(urlencode(json_encode($data)));

任何人都能纠正我的错误吗,谢谢你的帮助!

它是一个json对象,而不是数组。尝试

字符串jsoncontent=。。。

JSONObject JSONObject=新的JSONObject(jsoncontent);

最新更新