我從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 paser:
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 {
}
}
retSrc 是網站的長字符串
但是Log是:
Log.i("bird","eTitle:"+stock_data.getString("eTitle"));
沒有輸出任何東西.
我希望log是這樣的:
Mission: Impossible - Ghost Protocol Seediq Bale.....
JSONObject jObj=new JSONObject(retSrc);
JSONArray jArr=jObj.getJSONArray("movies");
for(int i = 0;i < result.length(); i++)
{
JSONObject stock_data = result.getJSONObject(i);
}