Hi,
I’m attempting to read ‘room’-info from a Json file. At the moment, I’m just trying to figure out how everything works. The next step would be to create a small room-editor for the game.
This is some (exploratory) code :
var scene1 = Json.parse(Json.stringify('assets/json/scene1_rooms.json'));
trace(Type.typeof(scene1)); // TClass([class String]) ???
I was expecting ‘Array’ as type, since this is (part of) my json-file :
[
{
"roomNr":1,
"bgImg" : "",
"nav" : {
"navL": 2
}
},
{
"roomNr":2,
"bgImg" : "",
"nav" : {
"navL": 3,
"navR": 1
}
}
]
The Json-file is valid ; I have checked it with this class ‘util.Validator’ and also with an online validator.
However, when I try to do this :
var scene1:Array<Dynamic> = Json.parse(...)
I get the following error :
//exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert "assets/json/scene1_rooms.json" to Array.
What am I doing wrong here ???