samedi 4 février 2017

Why isn't as3 handing my arrays in JSON?

Here I have this json file. { "BnUs5hQZkJWLU9jGlpx9Ifq5ocf2" : { "bio" : "Your bio!\r", "birthday" : "Date of Birth?", "location" : "Location?", "markerBorder" : 1.5542403222038021E7, "markerColor" : 8222122.31461079, "name" : "NamesName?", "profilePrivacy" : 2, "sex" : "Gender?", "trekPrivacy" : 2, "points" : { "-Kc7lfJk3XbPlNyk-wIR" : { "address" : "dsfsdfasfsfd", "description" : "status/desription", "latitude" : 35.2, "longitude" : -80.7, "mediaTargets" : "none", "pub" : false, "timestamp" : 1486205926658 }, "aaa" : "aaa" } } }

Those random string of charectors are automatically made when I use firebase.

In this scenario, there might be more "points" I will have to take account for. So when I reference points, I should be talking to an array since it contains both "Kc7lfJk3XbPlNyk-wIR" (an array) and "aaa" (a string).

So why do I get a type error when trying to convert parsedObject.points into an array?

var parsedObject:Object = JSON.parse(e.target.data);
var multiArray:Array = parsedObject.points;

TypeError: Error #1034: Type Coercion failed: cannot convert Object@5c16089 to Array.

I'm basically trying to do the opposite of what this guy is doing.

Aucun commentaire:

Enregistrer un commentaire