类型为org.json.JSONObject的poiComment上的值无法转换为JSONArray

时间:2013-08-19 17:28:01

标签: android json

早安的人, 我的头会爆炸导致这个错误

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"}}

0 个答案:

没有答案