JSONObject cannot be converted to JSONArray
来源:互联网 发布:淘宝店铺简介怎么修改 编辑:程序博客网 时间:2024/05/20 11:50
错误信息:org.json.JSONException: Value {"weatherinfo":{"city":"石家庄","cityid":"101090101","temp1":"2","temp2":"19","weather":"晴","img1":"n0.gif","img2":"d0.gif","ptime":"18:00"}} of type org.json.JSONObject cannot be converted to JSONArray
数据是 {"weatherinfo":{"city":"石家庄","cityid":"101090101","temp1":"2","temp2":"19","weather":"晴","img1":"n0.gif","img2":"d0.gif","ptime":"18:00"}}
数据地址:http://www.weather.com.cn/data/cityinfo/101090101.html
是不是因为这个json格式有问题?求大神解救!该如何解析这个json?
数据是 {"weatherinfo":{"city":"石家庄","cityid":"101090101","temp1":"2","temp2":"19","weather":"晴","img1":"n0.gif","img2":"d0.gif","ptime":"18:00"}}
数据地址:http://www.weather.com.cn/data/cityinfo/101090101.html
public static List<Weathers> getData(InputStream inputStream) throws IOException, JSONException {
byte[] data = StreamTools.read(inputStream);
JSONArray array = new JSONArray(new String(data));
List<Weathers> list = new ArrayList<Weathers>();
for (int i = 0; i < array.length(); i++ ){
JSONObject object =array.getJSONObject(i);
Weathers wea = new Weathers(object.getString("city"),
object.getString("cityid"),
object.getString("temp1"),
object.getString("temp2"),
object.getString("weather"),
object.getString("img1"),
object.getString("img2"),
object.getString("ptime"));
Log.i("NetJsonService","Weathers="+wea.toString());
list.add(wea);
}
return list;
}
是不是因为这个json格式有问题?求大神解救!该如何解析这个json?
0 0
- JSONObject cannot be converted to JSONArray
- model cannot be converted to JSONObject
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- JSONException:java.lang.String cannot be converted to JSONObject
- Volley String cannot be converted to JSONObject BOM
- JSONException: java.lang.String cannot be converted to JSONObject
- java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- Android : Value of type java.lang.String cannot be converted to JSONObject 异常
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- Android Studio调试问题!!!!!!!!!
- setPluginsEnabled(true);报错
- android objection push Notification where saves setting
- xcode 6.1.1 意外退出,无法打开应用程序一直提示reopen
- asp导出excel时在win2003下没有响应
- JSONObject cannot be converted to JSONArray
- ListView获取指定的item,然后去除它的分割线,困扰俩天了,求解
- android做开发时,能不能将服务器与客户端联网运行
- 想实现间隔1小时定位一次,怎么实现比较好
- Android地图应用开发 如何实现图源一键切换
- Android文件在线预览
- Iphone 视频播放 MP4 只有声音 图像是模糊
- 关于WebView和js的问题,急急急!!!
- 360手机平台上传应用签名文件丢失怎么升级呢