求指点这个问题
private List<NewBean> getJsonData(String url) {
List<NewBean> newBeanList = new ArrayList<NewBean>();//创建list
//获取json格式的数据
try {
String JsonString = readStream(new URL(url).openStream());
System.out.println(JsonString);
JSONObject jsonObject;
NewBean newBean;
jsonObject = new JSONObject(JsonString);
JSONArray jsonArray = jsonObject.getJSONArray("data");
System.out.println(jsonArray.length());
for (int i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);
newBean = new NewBean();
newBean.setNewsIconUrl(jsonObject.getString("picSmall"));
newBean.setNewsTitle(jsonObject.getString("name"));
newBean.setNewsContent(jsonObject.getString("description"));
newBeanList.add(newBean);
}
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return newBeanList;
}