0
我向服務器發送請求,並返回一個長的JSON塊。Actionscript 3,解析JSON數據問題
{
"response":"success",
"assignments":{
"17733":{
"asnid":"17733",
"asnname":"Yitzhak Rabin PPT",
"asnclass":"11276",
"asndue":"2011-10-03",
"asnnotes":"5 Slides in Hebrew",
"asnpriority":"0",
"asnstatus":"open"
},
"9811":{
"asnid":"9811",
"asnname":"Java Chapter 1",
"asnclass":"11270",
"asndue":"2011-09-09",
"asnnotes":"Review Exercises 1-14. Programming Exercises 1-6 ",
"asnpriority":"0",
"asnstatus":"done"
},
"9815":{
"asnid":"9815",
"asnname":"Hebrew Poems",
"asnclass":"11276",
"asndue":"2011-09-12",
"asnnotes":"1 Name based poem, and One byline poem. See sheet for further reference.",
"asnpriority":"0",
"asnstatus":"done"
},
"11096":{
"asnid":"11096",
"asnname":"Java Ethics Essay",
"asnclass":"11270",
"asndue":"2011-09-15",
"asnnotes":"",
"asnpriority":"0",
"asnstatus":"done"
}
}
}
爲了解析這些數據,我使用了com.adobe.serialization.json.JSON類。該類將數據轉換爲對象,但問題是我需要檢查對象「17733」或「9811」中的內容並獲取錯誤。 「1084:語法錯誤:期待rightparen前0.17733」
我的代碼如下:
if (task == "getAssignments")
{
//trace(loader.data);
var getAssnNumbers:Object = JSON.decode(loader.data);
//解碼JSON數據
for(var i:* in getAssnNumbers.assignments.17733)
{
assnNumbers.push(i);
trace(i);
}
//嘗試跟蹤存儲的數據在getAssnNumbers.assigments.17733 }
有沒有辦法做到這一點?我檢查了該屬性是否枚舉並返回true,但我無法找到訪問這些數據的方法。
Thaks這麼多!它現在有效。 – akadouri