JSON Export - Unknown GID References In Layer's Data Array

Hello all,

So, I’ve created a pretty simple 37x27 tile map, and I’ve exported it to a JSON file. Using the JSON Map Format, I’ve been able to parse it quite easily.

However, there is one bit that is confusing me, and I understand this question has been asked in different forms, but I haven’t seen an answer that truly makes me understand.

First off, since I’m a new user, so I was not able to upload my JSON file, so for now, I have to use this: http://s000.tinyupload.com/?file_id=97771536151311218352

So the general flow of my the deserializer is:

  1. Get the data array of GID’s from the layer, “Tile Layer 1” (which are presumably in order).
  2. Get a reference to the tileproperties from the tileset, “plains”
  3. Iterate over the data array and use each value as the key for the tileproperties dictionary. My assumption here is that the key is the tile ID it refers to

And this is where I run into problems. There is a tile ID = 50 in data, but that key does not exist in tileproperties. In fact, there is no tile with that ID in the editor at all. For whatever reason, the ID’s for my tiles goes from 49 and then skips to 52. shrugs

Now, I understand about firstgid (or at least I think I do). I was thinking it acted as an offset of sorts. For instance, I have a layer named “Units”. I also have a tileset called “units”. Under tileproperties, the ID’s go from 0 - 4, but then firstgid = 65, so if I add 65 to each of those ID’s, that maps directly to the IDs in the data array for the “Units” layer.

This, unfortunately does not work for the “Tile Layer 1” layer, so I’m at an impasse.

Sorry for the lenghy post, I just figured I would add as much information as possible so my issues are properly understood.

Thanks in advance to anyone who can answer these questions for me.


Leonard Bedner

…And right on cue…

Apologies for taking up space here, and potentially anyone’s time. I did understand firstgid, I just was doing the reverse math in order to make sense of the GUID’s in the data array.

I was adding the firstgid to each value I received from data, when I should have been subtracting it. Once I did that, I was able to use it as the key for the tileproperties, and everything worked as expected.

Again, sorry for the confusion.

1 Like

Nice to hear you’ve solved it and thanks for letting us know what the problem was!