{"feed":[{"image":"http:\/\/xyz\/xyz\/600x519\/web2images\/www.xyz.com\/2015\/09\/16\/xyz.jpg","story_id":"83","slug_intro":"xyz","title":"xyz","videoflag":0,"version":"2","channel_slno":"123","pubdate":"2015-09-17 00:08:00"}],"bigimage":0}
请在JAVA中提供代码。
请说明为什么我收到此错误,如上图所示
答案 0 :(得分:2)
String myJSONString = "{\"feed\":[{\"image\":\"http://xyz/xyz/600x519/web2images/www.xyz.com/2015/09/16/xyz.jpg\",\"story_id\":\"83\",\"slug_intro\":\"xyz\",\"title\":\"xyz\",\"videoflag\":0,\"version\":\"2\",\"channel_slno\":\"123\",\"pubdate\":\"2015-09-17 00:08:00\"}],\"bigimage\":0}";
JSONObject json = new JSONObject(myJSONString);
JSONArray dataJsonArray = json.getJSONArray("feed");
for(int i=0; i<dataJsonArray.length; i++) {
JSONObject dataObj = dataJsonArray.get(i);
String title = dataObj.getString("title");
//Similarly you can extract for other fields.
}
输出:Title:xyz