I am able to pull JSON data from PHP into my Flex application just fine with the following bit of code:
public function httpResult(event:ResultEvent):void {
var rawData:String = String(event.result);
trace(String(event.result)); //shows correct order
var as3Data:Object = JSON.decode(rawData);
for (var i:* in as3Data) {
trace(i + ": " + as3Data[i].unit_price); //shows incorrect order
}
}
When I trace the result, I see the information I am pulling in the correct order.
{"100":{"unit_price":"2.9567"},"400":{"unit_price":"1.0991"},"800":{"unit_price":"0.7926"},"1200":{"unit_price":"0.6911"}} {
But, once I JSON.decode the result, somehow it re-orders the content. And, puts the first item last.
400: 1.0991, 800: 0.7926, 1200: 0.6911, 100: 2.9567
Does anyone have any ideas on why it would be doing this? Or ideas on how I can re-order the Object myself?