2012年10月27日 星期六

Android程式設計 - JSON資料處理(3)

使用JSONArray
JSONArray類別透過位置索引值來取得該位置的名稱/」資料對之值,常用方法如下:
l String getString (int index)
取得指定索引位置之字串值。
index        名稱/」資料對之位置索引值,從0開始。
l boolean getBoolean (int index)
取得指定索引位置之布林值。
index        名稱/」資料對之位置索引值,從0開始。
l double getDouble (int index)
取得指定索引位置之倍精準數值。
index        名稱/」資料對之位置索引值,從0開始。
l int getInt (int index)
取得指定索引位置之整數值。
index        名稱/」資料對之位置索引值,從0開始。
l long getLong (int index)
取得指定索引位置之長整數值。
index        名稱/」資料對之位置索引值,從0開始。
l JSONArray getJSONArray (int index) 
取得指定索引位置之JSONArray值。
index        名稱/」資料對之位置索引值,從0開始。
l JSONObject get JSONObject (int index) 
取得指定索引位置之JSONObject值。
index        JSONObject名稱/」資料對之位置索引值,從0開始。