JSONObject Obj = new JSONObject(params);
JSONObject Weatherinfo = Obj.getJSONObject("HeWeather5");//解析Heweather5
是不是报错 JSONObject["HeWeather5"] is not a JSONObject.
换成Obj.getJSONArray
http://blog.csdn.net/risingsun001/article/details/18600869
你的HeWeather5代表的是个数组,用getJSONArray,你的HeWeather5要转为JSONArray
JSONObject Obj = new JSONObject(params);
JSONObject Weatherinfo = Obj.getJSONObject("HeWeather5");//解析Heweather5
改成
JSONObject Obj = new JSONObject(params);
JSONArray Weatherinfo = Obj.getJSONArray("HeWeather5");//解析Heweather5
HeWeather5是一个数组。使用Gson框架来解析比较方便
用JSONObject去解析JSONArray,肯定会出错的呀。
首先 解析方式出错,jsonarray用了jsonobject解析;其次,建议使用三方json框架,比如gson、fastjson等,例如fastjson,此处如果用fastjson解析
JSONObject Obj = JSON.parseObject(params);
JSONObject Weatherinfo = Obj.getJSONObject("HeWeather5");//解析Heweather5
会提示你HeWeather5中有[]是一个array
正确方式
JSONArray Weatherinfo = Obj.getJSONArray("HeWeather5");//解析Heweather5