Hey,
I'm having a problem parsing a JSON file in AS3. Im trying to parse multiple JSON arrays, but don't really know how to get to the next after accessing the first one. My JSON file looks like:
{
"term": [
{
"id": 4211,
"place": "NEW YORK CITY"
},
{
"id": 2675,
"place": "WASHINGTON (DC)"
}
],
"term": [
{
"id": 4211,
"place": "NEW YORK CITY"
},
{
"id": 2675,
"place": "WASHINGTON (DC)"
}
]
}
My AS3 code looks like:
public function parseData(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
var values:Object = JSON.decode(loader.data);
var term:Array = values.term;
var counter:Number = 0;
for (var key:Object in term)
{
payload[counter] = [term[key].id, term[key].place];
counter++;
}
dispatchEvent(new Event(Event.COMPLETE));
}
I can get the data from the first array, but how would I structure my code so that I could iterate through 2 or more "term" arrays?
Thanks