baylej/tmx

Worlds

RobLoach opened this issue · 3 comments

Be able to load .world World data, along with all the associated maps.

It's JSON, so that means we'd need a JSON library, unfortunately. Perhaps best handled outside of the tmx library as an addon?

There used to be a JSON importer in libTMX using the jansson library, but supporting two file formats that have the exact same features was too much work for me only.
As XML is the historical format and the main format, and as the JSON format is more of an export format, plus the JSON produced by Tiled is considered inconsistent and unconventional by the creator of Tiled (mapeditor/tiled#3212), I decided to drop support for the JSON format.

Unfortunately the JSON fomat has been choosen for world files instead of XML, I was puzzled when the news came out first, is my project (libTMX) obsolete? will JSON supercede XML as the main format to encode maps as well?

For now I decided to do nothing and let users of LibTMX handle these world files.

bjorn commented

Unfortunately the JSON fomat has been choosen for world files instead of XML, I was puzzled when the news came out first, is my project (libTMX) obsolete? will JSON supercede XML as the main format to encode maps as well?

I don't think this library is obsolete. It may just make sense to bring back JSON support in the future, potentially dropping the XML format instead to save some work.

It just seems to me that in general, in the past decade JSON has mostly replaced XML as common interchange format. That started with HTTP APIs of course, but it is also seen in recent standards like glTF 2.0, and game development tools, like GameMaker switching from XML to JSON. I think the main reason is that it's easier to parse, often even directly into strongly typed classes, making it very convenient to work with.

So, in trying to make working with Tiled maps as easy as possible, I'm leaning towards defaulting to a JSON based format in the future, though probably only after those issues with the current format have been addressed. New features like the worlds and the recently added export of "property types" only support JSON, since coding support for multiple file formats for each new asset makes things more complex and I don't really see a benefit in doing that.

Thanks for clarifying the situation.
I'll revive the json loader when Tiled fully adopts json as its main format.
There will probably be a feature gap because that code is old, also some features provided by the libxml2 don't exist in the json parser.