Hello,
I’m importing data via JSONParse. The data imports fine. I’m having a problem accessing it.
How do I reference a multidimensional array/object once the data has been loaded?
For example this code works:
levelDataRaw = Resources.Load("Levels") as TextAsset;
levelData = JSONParse.JSONParse(levelDataRaw.ToString()) as Hashtable;
for (var level : Hashtable in levelData['levels'])
{
print(level["data"]);
}
but when I try to access anything beneath data like this, it does not:
print(level["data"]["blocks"]);
This throws the following error: Type object does not support slicing.
This is the JSON data that appears to be loading in fine:
{
"levels" : [
{
"number" : 1,
"name" : "Level 1",
"width" : 10,
"height" : 8,
"author" : "Tester",
"data" :
{
"blocks" : [
{
"x" : 2,
"y" : 1
},
{
"x" : 3,
"y" : 1
}
]
}
}
]
}