所以我有這個JSON,然後我的活動中檢索到的字符串:解析JSON成一個ListView友好的輸出
{"popular":
{"authors_last_month": [
{
"url":"http://activeden.net/user/OXYLUS",
"item":"OXYLUS",
"sales":"1148",
"image":"http://s3.envato.com/files/15599.jpg"
},
{
"url":"http://activeden.net/user/digitalscience",
"item":"digitalscience",
"sales":"681",
"image":"http://s3.envato.com/files/232005.jpg"
}
{
...
}
],
"items_last_week": [
{
"cost":"4.00",
"thumbnail":"http://s3.envato.com/files/227943.jpg",
"url":"http://activeden.net/item/christmas-decoration-balls/75682",
"sales":"43",
"item":"Christmas Decoration Balls",
"rating":"3",
"id":"75682"
},
{
"cost":"30.00",
"thumbnail":"http://s3.envato.com/files/226221.jpg",
"url":"http://activeden.net/item/xml-flip-book-as3/63869",
"sales":"27",
"item":"XML Flip Book/AS3",
"rating":"5",
"id":"63869"
},
{
...
}],
"items_last_three_months": [
{
"cost":"5.00",
"thumbnail":"http://s3.envato.com/files/195638.jpg",
"url":"http://activeden.net/item/image-logo-shiner-effect/55085",
"sales":"641",
"item":"image logo shiner effect",
"rating":"5",
"id":"55085"
},
{
"cost":"15.00",
"thumbnail":"http://s3.envato.com/files/180749.png",
"url":"http://activeden.net/item/banner-rotator-with-auto-delay-time/22243",
"sales":"533",
"item":"BANNER ROTATOR with Auto Delay Time",
"rating":"5",
"id":"22243"},
{
...
}]
}
}
可以訪問here爲好,儘管它,因爲它是一個相當長的字符串,我已將上述內容修剪至顯示所需內容。
基本上,我希望能夠訪問「items_last_week」中的項目並創建它們的列表 - 最初我的計劃是在其左側的「項目」左側具有「縮略圖」,但是從今天玩了SDK,看起來太難或不可能實現這一點,所以我只會從列表中的'items_last_week'擁有'item'數據而感到高興。
來自php我很努力地使用任何可用於Java的JSON庫,因爲它似乎遠不止一行代碼,我需要反序列化(我認爲這是正確的詞) JSON,他們都似乎需要某種形式的額外的類,除了JSONArray/JSONObject腳本我不喜歡這樣一個事實,即items_last_week嵌套(再次,我認爲這是JSON術語),並需要一個可怕的長期有時間在Android模擬器上運行。
所以,實際上,我需要一個(最好是簡單的)方式將items_last_week數據傳遞給ListView。我知道我需要一個自定義適配器,我可能會把我的頭轉過來,但我無法理解,無論我花了多少時間試圖找出它,如何訪問JSON字符串的某些部分..
你需要Json幫助嗎?然後你可以添加Json標籤到你的問題。 – tbruyelle 2009-12-30 22:19:18
「java」標籤也是適合的。 – 2009-12-30 23:31:28