我正在尝试将从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变量,则转换成功,不知道是怎么回事。请帮忙。