private List<NewsBean> getJsonDate(String url) { List<NewsBean> newsBeanlist = new ArrayList<NewsBean>(); try { String jsonString = readStream(new java.net.URL(url).openStream());// Log.i("log",jsonString); JSONObject jsonObject; NewsBean bean; jsonObject = new JSONObject(jsonString); JSONArray jsonArray = jsonObject.getJSONArray("data"); for(int i = 0; i<jsonArray.length(); i++) { jsonObject = jsonArray.getJSONObject(i); bean = new NewsBean(); bean.newsIconurl = jsonObject.getString("picSmall"); bean.newsTitle = jsonObject.getString("name"); bean.newsContent = jsonObject.getString("description"); newsBeanlist.add(bean); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return newsBeanlist; }
- 1 回答
- 1 关注
- 1068 浏览
添加回答
举报
0/150
提交
取消