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;
}
黎明鸟飞去
相关分类