在android Http有一個很長的字符串:
{"movies":[
{"movieId":"fmen71229238","eTitle":"Mission: Impossible - Ghost Protocol","cTitle":"不可能的任務:鬼影行動","imageUrl":"http://test.mobibon.com.tw/MovieGoTest/Pics/pl_fmen7122923814_s.jpg","releaseDate":"2011/12/15","saleType":"0"},
{"movieId":"fstw79905171","eTitle":"Seediq Bale","cTitle":"賽德克.巴萊(上)太陽旗","imageUrl":"http://test.mobibon.com.tw/MovieGoTest/Pics/pl_fstw7990517114_s.jpg","releaseDate":"2011/9/9","saleType":"0"},
{"movieId":"fytw91390391","eTitle":"You Are the Apple of My Eye","cTitle":"那些年,我們一起追的女孩","imageUrl":"http://test.mobibon.com.tw/MovieGoTest/Pics/pl_fytw9139039102_s.jpg","releaseDate":"2011/8/19","saleType":"0"}
]}
字符串是JSON格式,我希望它在不同的數組中排序,然後顯示在Listview中,我使用以下的JSON parser。retSrc是一個長字符串。
JSONArray result = new JSONArray(retSrc);
for(int i = 0;i < result.length(); i++)
{
JSONObject stock_data = result.getJSONObject(i);
Log.i("bird","eTitle:"+stock_data.getString("eTitle"));
}
} finally {
}
}
Log文件Log.i("bird","eTitle:"+stock_data.getString("eTitle"));
什麼都沒記錄,我希望log文件是這樣:Mission: Impossible - Ghost Protocol Seediq Bale.....etc
怎麼在Listview中顯示呢?Log文件是什麼樣的呢?
你也可以使用Gson,給API提供Json解析。這個很簡單,你只需要創建你想用的對象的類型。