JSON解析错误。

时间:2012-02-21 11:49:39

标签: android json parsing gson

我正在尝试将从Web服务返回的json字符串转换为android上的本地类对象。

但收到错误:java.lang.String无法转换为JSONArray

返回的字符串是:

[{"Id":592,"RadioName":"CRI怀旧金曲(128Kbps)","RadioAddress":"mmst","Priority":0,"GroupId":14,"GroupDesc":"热门","RadioCountry":"China(中国)","Valid":1,"Vip":0,"LanguageDesc":"China(中国)"},{"Id":594,"RadioName":"猫扑网络电台(32Kbps)","RadioAddress":"mmst","Priority":1,"GroupId":14,"GroupDesc":"热门","RadioCountry":"China(中国)","Valid":1,"Vip":0,"LanguageDesc":"China(中国)"}] 

我正在使用的代码是:

            String result= convertStreamToString(instream);
            try {
                JSONArray responseObject = new JSONArray(result);

            } catch (JSONException e) {
                e.printStackTrace();
            }

如果我手动将上面返回的字符串分配给String变量,则转换成功,不知道是怎么回事。请帮忙。

0 个答案:

没有答案