开发者

Actionscript 3, Parsing JSON Data problem

I am sending a request to a server, and i开发者_StackOverflow社区n return I get a long block of 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"
    }
  }
}

In order to parse this data I was using the com.adobe.serialization.json.JSON class. The class turned the data into objects but the problem is I need to check whats in object "17733" or "9811" and get an error. " 1084: Syntax error: expecting rightparen before .17733"

My code is the following:

if (task == "getAssignments")
    {
        //trace(loader.data);
        var getAssnNumbers:Object = JSON.decode(loader.data);

//Decode JSON Data

        for(var i:* in getAssnNumbers.assignments.17733)
        {
            assnNumbers.push(i);
            trace(i);
        }

//Try to trace the data stored in getAssnNumbers.assigments.17733 }

Is there a way to do this? I checked if the property was enumerated and it returned true, but I cant find a way to access this data.


Try accessing your property using the bracket notation:

getAssnNumbers.assignments["17733"]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜