Help with JSON (again)
Posted: Thu Oct 29, 2020 2:58 pm
Hi PB'ers -
I have had a look on the forum and there's lots of posts regarding reading bits of JSON but nothing that I've been able to refer to to help do what I need: I have an exported JSON from with Tiled - I need to read the "layers" element, the pull out that data. I've tried freak's structurer creator but still cannot achieve what I need.
My Json looks like this which I load in from a file :
I've tried copying the pointer structures to the arrays, but it only goes so deep.
I have had a look on the forum and there's lots of posts regarding reading bits of JSON but nothing that I've been able to refer to to help do what I need: I have an exported JSON from with Tiled - I need to read the "layers" element, the pull out that data. I've tried freak's structurer creator but still cannot achieve what I need.
My Json looks like this which I load in from a file :
Code: Select all
{ "compressionlevel":-1,
"editorsettings":
{
"export":
{
"target":"."
}
},
"height":176,
"infinite":false,
"layers":[
{
"data":[2, 2, 2, 2, ... trimmed ],
"height":176,
"id":9,
"name":"Map",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":160,
"x":0,
"y":0
},
{
"draworder":"topdown",
"id":2,
"name":"Entities",
"objects":[
{
"height":16,
"id":63,
"name":"Start",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":32,
"y":144
},
{
"height":16,
"id":64,
"name":"Exit",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":208,
"y":144
},
{
"height":16,
"id":65,
"name":"Key",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":24,
"y":24
},
{
"height":16,
"id":66,
"name":"Time",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":928,
"y":120
},
{
"height":16,
"id":67,
"name":"undead",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":64,
"y":96
},
{
"height":16,
"id":72,
"name":"Bonus",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":224,
"y":24
},
{
"height":16,
"id":73,
"name":"Shield",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":856,
"y":120
},
...etc