Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsonformat #1868

Merged
merged 11 commits into from
Jan 30, 2018
Merged

Jsonformat #1868

merged 11 commits into from
Jan 30, 2018

Conversation

saeedakhter
Copy link
Contributor

Addresses issue #1585

This introduces a new json revision (version: 1.2) that is much easier to serialize and de-serialize. For an example of de-serializing the new format in Unity3d, see https://github.com/saeedakhter/TiledJsonUnity3d

Problem:
Tiles were serialized as a map with the tile ID as the key:

"tiles":
    {
     "0": { "image":"necro3_0\/5.png", "imageheight":32, "imagewidth":32 },
     "1": { "image":"necro3_0\/4.png", "imageheight":32, "imagewidth":32 }
    }

In Unity3d, this makes it difficult (impossible?) to use Unity3d's JSON deserialization:
https://docs.unity3d.com/Manual/JSONSerialization.html

Solution (this pull request):
Serialize tiles and properties as a list. If an ID is required, put it inside the list object. Example:

 "tiles":[
        {
         "terrain":[0, 2, 2, 2],
         "tile":0
        }, 
        {
         "properties":[
                {
                 "name":"Prefrab",
                 "type":"string",
                 "value":"Floor*"
                }, 
                {
                 "name":"SortingLayer",
                 "type":"string",
                 "value":"Floor"
                }],
         "terrain":[0, 0, 0, 0],
         "tile":1
        }, 

bjorn added 3 commits January 30, 2018 13:29
The format is still mostly the same, so the code for reading all the tile
attributes can be shared.
@bjorn bjorn merged commit 1d9ca3c into mapeditor:master Jan 30, 2018
@bjorn
Copy link
Member

bjorn commented Jan 30, 2018

Thanks a lot for your work on this!

@bitinn
Copy link

bitinn commented Feb 28, 2018

Thx for your good work @saeedakhter!

Just wondering @bjorn, does the snapshot build contain this change? I was writing a parser on C# for my specific use-case and realize it would have been much easier with this updated properties field instead of the old tileproperties as I just happen to heavily rely on tileset properties.

@bjorn
Copy link
Member

bjorn commented Feb 28, 2018

@bitinn Yes, the changes are included in the latest snapshot build. The JSON format documentation is also already updated, which means it's now actually time to host explicit "Tiled 1.1" documentation (probably as default) as well to avoid confusion.

@bitinn
Copy link

bitinn commented Feb 28, 2018

@bjorn fantastic! and yeah I was reading the doc and realize tileproperties was missing and find my way here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants