I've a json and have that part of the code that contains the botom section that have 6 sections that on a json viewer was ordered from 0 to 5...
Code: Select all
"tilesets":[
{
"columns":4,
"firstgid":1,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Character\/Idle\/Idle.gif",
"imageheight":80,
"imagewidth":64,
"margin":0,
"name":"TESTmap1 PERSONAGGIO",
"spacing":0,
"tilecount":20,
"tileheight":16,
"tilewidth":16
},
{
"columns":25,
"firstgid":21,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Assets\/Buildings.png",
"imageheight":400,
"imagewidth":400,
"margin":0,
"name":"TESTmap1 builgdings",
"spacing":0,
"tilecount":625,
"tileheight":16,
"tilewidth":16
},
{
"columns":25,
"firstgid":646,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Assets\/Tiles.png",
"imageheight":400,
"imagewidth":400,
"margin":0,
"name":"TESTmap1 TILEs",
"spacing":0,
"tilecount":625,
"tileheight":16,
"tilewidth":16
},
{
"columns":56,
"firstgid":1271,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Trees\/Background.png",
"imageheight":256,
"imagewidth":896,
"margin":0,
"name":"TESTmap1 BACKGROUND",
"spacing":0,
"tilecount":896,
"tileheight":16,
"tilewidth":16
},
{
"columns":84,
"firstgid":2167,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Trees\/Green-Tree.png",
"imageheight":1200,
"imagewidth":1344,
"margin":0,
"name":"TESTmap1 Green Trees",
"spacing":0,
"tilecount":6300,
"tileheight":16,
"tilewidth":16
},
{
"columns":30,
"firstgid":8467,
"image":"..\/..\/ASSETS\/TEST\/Legacy-Fantasy - High Forest 2.0\/Legacy-Fantasy - High Forest 2.3\/Background\/Background.png",
"imageheight":272,
"imagewidth":480,
"margin":0,
"name":"TestMAp1 - SFONDO",
"spacing":0,
"tilecount":510,
"tileheight":16,
"tilewidth":16
}],
My problem was that after Deserializing it when I try to:
Code: Select all
NPrint(t.tilesets)
but:
Code: Select all
NPrint(t.tilesets.0)
Error in line 31 (ReadJSON2.hws): Opening bracket expected!
Why?
My fault or some limitation on Deserialize JSON?
Thank you!
HOW I can access to the 6 sub tables in "tilesets" section?
EDIT : that was the code I use:
Code: Select all
@DISPLAY {Width = 480, Height = 620, Color = #WHITE, Sizeable = True}
SetFont(#SANS, 28)
SetFontStyle(#ANTIALIAS)
SetFontColor(#BLACK)
InstallEventHandler({SizeWindow = p_PrintText})
map$ , mapbyte = FileToString("MAPPA/test.json")
DebugPrint("mapbyte ...." , mapbyte)
DebugPrint("map$ ...." , map$)
SetSerializeMode(#SERIALIZEMODE_NAMED)
map = DeserializeTable(map$)
NPrint("TABLE ITEMS...........", TableItems(map))
NPrint(map)
NPrint("type ...." , map.type)
NPrint("version ...." , map.version)
NPrint("layers...." , map.layers)
NPrint("layers id...." , map.tiledversion)
NPrint("tilesets...." , TableItems(map.tilesets))
NPrint("tilesets...." , map.tilesets)
NPrint("renderorder...." , map.renderorder)
prova = map.tilesets.2
NPrint("prova....", prova)
Repeat
WaitEvent
Forever