# Off By One in JSON Export?

**URL:** <https://discourse.mapeditor.org/t/off-by-one-in-json-export/1921>\
**Category:** Questions\
**Created:** [December 29, 2016, 10:38pm UTC](https://discourse.mapeditor.org/t/off-by-one-in-json-export/1921 "2016-12-29T22:38:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![3v1L](https://avatars.discourse-cdn.com/v4/letter/3/258eb7/32.png) [@3v1L](https://discourse.mapeditor.org/u/3v1L)\
**Post date:** [December 29, 2016, 10:38pm UTC](https://discourse.mapeditor.org/t/off-by-one-in-json-export/1921/1 "2016-12-29T22:38:13Z")

</div>

Tile codes are being stored using different representations in different parts of my JSON export file. For example, if the tile map grid shows that there is tile 140 at some index, the tile metadata is stored as 139 elsewhere in the JSON object. Let me elaborate…

I have created a map and edited certain tiles in the Collision Editor to have collision rectangles. After I export to a JSON file, I find my layers and map array in jsonObject.layers[0].data, where at the tile index there is the number representing my tile. In my case it displays 140, representing the 140th tile in my sheet.

When I look at the tile information in jsonObject.tilesets[0] though, the objectgroup info for the tile in question is stored under index 139, which is one off.

I was hesitant to post this under the bug tag because I realize it might actually be a feature, or perhaps it is because it is representing the “index” of an array, but as it appears to me this structure is closer to a JS object rather than an array anyway. At any rate I thought I’d ask the opinion of the community. If it is a bug then let’s fix it!

Thanks

---

<div class="post-metadata">

**Author:** ![3v1L](https://avatars.discourse-cdn.com/v4/letter/3/258eb7/32.png) [@3v1L](https://discourse.mapeditor.org/u/3v1L)\
**Post date:** [December 29, 2016, 10:50pm UTC](https://discourse.mapeditor.org/t/off-by-one-in-json-export/1921/3 "2016-12-29T22:50:05Z")

</div>

Duplicate - I found my answer in another post. Nothing to see here!

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [January 5, 2017, 11:43am UTC](https://discourse.mapeditor.org/t/off-by-one-in-json-export/1921/4 "2017-01-05T11:43:34Z")

</div>

Just for future reference in case people stumble upon this thread, I assume the post you found is the following one:

> [@Array files are one number off from tile set](http://discourse.mapeditor.org/t/array-files-are-one-number-off-from-tile-set/1884):
>
> Hi there I’ve been playing around with the map editor as it’s easier than my regular tilemap editor plus I can print out the integer arrays. The problem is that when ever a export my map as a text file like .json the integers are always 1 off. For instance tile number 0 shows up as 1 and 1 shows up as 2 and so on. It’s weird because in the app and clicking on tile properties it tells you that tile number 0 should be labeled tile 0. Is there a way to fix it so it shows tile numbers in the ord…
