大家早上好,我的头会因为这个错误而爆炸
org.json.JSONObject 类型的 poiComment 中的值 {...} 无法转换为 JSONArray
这是json文件:
{
"poiComment": [
{
"id": "1",
"poiComment": "I'm at The Pine. http://4sq.com/a1UXvc"
},
{
"id": "2",
"poiComment": "bday dinner w. my bff <3 (@ The Pine) http://4sq.com/a1UXvc"
},
{
"id": "3",
"poiComment": "I'm at The Pine. http://4sq.com/a1UXvc"
}
]
}
我使用这种方式(上次我使用它工作的jsonobject):
JSONObject jso1 = new JSONObject(response1);
JSONArray jArray1 = jso1.getJSONArray("poiComment");
这怎么可能??
提前感谢您的帮助
这就是解析器所做的
private String inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
// Read response until the end
while ((line = rd.readLine()) != null) {
total.append(line);
}
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
// Return full string
return total.toString();
}
这就是解析器产生的结果!!!????!!!??! 怎么可能?:(
{"poiComment":{"id":"1","poiComment":"Nadoori no more. Watching peeps plan a new restaurant, Yuba (@ Nadoori) http://4sq.com/8yVoey"}}