Why does trace(length) return 1? I expected it to be 3.
How would I loop through each screen object?
appData:Object = JSON.parse {
"screen":
{
"type": "Title",
"title":
{
"en":"",
"ae":""
},
"content":
{
"en":"",
"ae":""
}
},
"screen":
{
"type": "Text",
"title":
{
"en":"",
"ae":""
},
"content":
{
"en":"",
"ae":""
}
},
"screen":
{
"type": "Map",
"title":
{
"en":"",
"ae":""
},
"content":
{
"en":"",
"ae":""
}
}
};
var length:uint = 0;
for ( var s:* in appData)
{
length++
}
trace(length);
The problem is with your JSON structure. You’re using the “screen” property name multiple times, and these need to be unique. Alternatively, you could use an Array structure here.