mapeditor/tiled

JSON export changed between versions

Closed this issue ยท 11 comments

Hi,

why do we have different .json exports at version 1.1.7 and newest release?

screenshot 2019-01-05 12-20-51

And how can we still export the old way with a new version of tiled?

PS: Our Designer does support you through Patreon...

bjorn commented

why do we have different .json exports at version 1.1.7 and newest release?

I'm sorry this change caused you trouble! Please read my answer at #2034 (comment) for the rationale behind this change and a possible solution.

And how can we still export the old way with a new version of tiled?

At the moment this is not possible, since I thought the new format would always be easier to read. If it isn't trivial to update your code or if the previous format suited you better, please let me know and I'll see what I can do.

PS: Our Designer does support you through Patreon...

Thanks a lot for that! Because of Patreon I am able to keep improving Tiled (at the moment I'm adding support for scripting, which can soon also be used to output maps in custom formats).

okay, I will look into it and let you know. I just want that our designer can use the newest version(s). The properties stuff shouldn't be of too much concern, since we make that parsing. Though, I red in the changelog (https://doc.mapeditor.org/en/stable/reference/json-map-format/#changelog) "The tiles in a Tileset are now stored as an array instead of an object", I am rather worried about that change, which is parsed by Phaser-Ce (resp. https://github.com/englercj/phaser-tiled).

In general, it would be great, if newer versions of Tiled would support older output formats, except there is some technical need. I understand that annotation-based automated parsing systems may have had trouble with the old format, though you could have just added a second JSON output for those systems.

Anyways, your software became a crucial part of our game develop process and we are very glad to have tiled. So, which ever decisions you make... its fine. But its kinda the same issue as with the web, backwards compatibility.

bjorn commented

I am rather worried about that change, which is parsed by Phaser-Ce (resp. https://github.com/englercj/phaser-tiled).

Ah, that is a good reason to worry since this library seems unmaintained since 1.5 years and its documentation mentions that it supports Tiled up to version 0.15... If this library is still relevant (like, doesn't have a better alternative in the meantime), I could look into making the needed adjustments and doing a PR. It should simplify the code, since there is no longer a need to do weird stuff like:

https://github.com/englercj/phaser-tiled/blob/90aca84f9eb382ed9fe6c5bcfa08cdbc2209d6f2/src/tiled/Tileset.js#L41-L43

In general, it would be great, if newer versions of Tiled would support older output formats, except there is some technical need.

This is mostly a question about maintenance. It would be quite a bit more effort to maintain different versions of the format and adding the option to choose which format to use. But of course, updating all those libraries is also a big effort.

Maybe I made the wrong call here, since quite a few people ran into this change unexpectedly.

Phaser 2/CE has had pixi.js as its rendering engine. Phaser, never really optimized the rendering of tiles. Thanks to @englercj, a pixi developer, has solved this problem with phaser-tiled, which makes Phaser 2/CE run large tilemaps with good performance. (basically it just doesn't render tiles which are out of bound/camera)

Phaser 3, just kinda got production ready and it now has its own rendering engine and uses matter.js, but this kinda makes it nearly impossible to migrate, especially far progressed projects, like ours. I don't know any numbers of how many people use the combination of Phaser2/CE with phaser-tiled. But according to the newsletter @phaser, still the majority of game releases are Phaser2/CE, while the number of Phaser 3 games is growing, though. The export format change of Tiled 1.2, will effect them anyways... with or without phaser-tiled.

In this case, making it possible to still export the old way, would solve all issues, while updating game frameworks to accept the new format, will be more a barrel without a hole.
I assume that I am just part of the first wave of complains... probably a lot of people have relied on the JSON export and possibly a lot haven't yet updated their Tiled, although its already 2 month, but our designer (Leveldesigner), just ran into it now.

Hello! I indeed stopped working on phaser-tiled because it got to a point where it "just worked" for the popular versions of both libraries and I supported the feature set I was interested in having.

Later I made gl-tiled which is a WebGL-only renderer for Tiled maps, but that was based on v1.0.

Both of these projects are likely not to work with the latest version of Tiled JSON output, but I'm more than happen to merge PRs that fix them up if anyone was interested. I'm not currently working on a project that uses Tiled, but I may in the near future at which point I'd update gl-tiled, but not phaser-tiled (I don't use Phaser anymore).

bjorn commented

@englercj Thanks for dropping by! I checked out your gl-tiled demo and that's some awesome map rendering performance! I hope you'll continue work on it. :-)

@Weedshaker So, I've looked into multiple ways to still support the old format:

  • Adding them to the JSON plugin as additional file formats.
  • Adding an option to the Preferences to tell Tiled to use the old format.
  • Adding another JSON plugin that uses the old format.

In the end I went for the last option, since I think it's the cleanest approach (less confusing the users with choices or options). The new "json1" plugin is disabled by default, so it won't bother those who don't need it. And those that do can disable the "json" plugin when enabling the "json1" plugin, so that the format can still be selected automatically based on the file extension without ambiguity.

I plan to release Tiled 1.2.2 tomorrow, which will include the json1 plugin.

Thank you very much for your effort. This has been super fast! Looking forward to test this on 1.2.2 tomorrow! Greetz

bjorn commented

Sorry, the build for macOS on Travis CI was broken and I spent the whole day fixing it, running into one problem after another. Now it's too late to make a release, and tomorrow I need to be back to work, so unless I find enough time in the evenings I may need to postpone the release till Tuesday next week. :/

Easy, we all have to struggle at our paying day jobs. Thanks for the info, though and don't even dare to work on this in the evenings. Next Tuesday is more than soon enough!

bjorn commented

Hehe, thanks @Weedshaker! Unfortunately it's too late not to work on this in the evenings... Since the last builds have been running fine, I've pushed the v1.2.2 tag and will test what has been uploaded tomorrow. Maybe I'll find some time to announce it anyway.

Yes 1.2.2 works like a charm! THANK YOU!

Below a little instruction for people who may read this post in the future.
This is how you enable old style JSON export:

  1. Download Version >= 1.2.2
  2. Click Edit/Preferences/Plugins and select libjson1.so
    screenshot_30_01_19__15_47
  3. File/Export as JSON map files [Tiled 1.1]
    screenshot_30_01_19__15_48
    (Note: this export option is available, as soon as you select the libjson1.so plugin)