JSON Kartenformat

Tiled kann Karten als JSON-Dateien exportiern. Wählen Sie dazu einfach „Datei > Exportieren unter“ und wählen Sie den JSON-Dateityp. Sie können Json von der Kommandozeile mit der Option --export-map exportieren.

The fields found in the JSON format differ slightly from those in the TMX Map Format, but the meanings should remain the same.

The following fields can be found in a Tiled JSON file:

Karte

Feld Type Description
backgroundcolor Zeichenkette Hex-formatierte Farbe (#RRGGBB or #AARRGGBB) (optional)
Höhe Ganzzahl (int) Anzahl der Tiles-Zeilen
hexsidelength Ganzzahl (int) Length of the side of a hex tile in pixels (hexagonal maps only)
unendlich Boolean (wahr/falsch) Ob die Karte unendliche Dimensionen hat
Layer Array Array of Layers
nextlayerid Ganzzahl (int) Auto-increments for each layer
nextobjectid Ganzzahl (int) Auto-increments for each placed object
Ausrichtung Zeichenkette orthogonal, isometric, staggered or hexagonal
properties Array Array of Properties
Zeichenreihenfolge Zeichenkette right-down (the default), right-up, left-down or left-up (orthogonal maps only)
staggeraxis Zeichenkette x or y (staggered / hexagonal maps only)
staggerindex Zeichenkette odd or even (staggered / hexagonal maps only)
tiledversion Zeichenkette The Tiled version used to save the file
Tile-Höhe Ganzzahl (int) Map grid height
Tilesets Array Array of Tilesets
Tile-Breite Ganzzahl (int) Map grid width
Typ Zeichenkette map (since 1.0)
Version Nummer Die JSON-formatierte Version
Breite Ganzzahl (int) Number of tile columns

Beispielkarte

{
  "backgroundcolor":"#656667",
  "height":4,
  "layers":[ ],
  "nextobjectid":1,
  "orientation":"orthogonal",
  "properties":[
    {
      "name":"mapProperty1",
      "type":"one",
      "value":"string"
    },
    {
      "name":"mapProperty2",
      "type":"two",
      "value":"string"
    }],
  "renderorder":"right-down",
  "tileheight":32,
  "tilesets":[ ],
  "tilewidth":32,
  "version":1,
  "tiledversion":"1.0.3",
  "width":4
}

Ebene

Feld Type Description
chunks Array Array of chunks (optional). tilelayer only.
compression Zeichenkette zlib, gzip or empty (default). tilelayer only.
Daten array or string Array of unsigned int (GIDs) or base64-encoded data. tilelayer only.
Zeichenreihenfolge Zeichenkette topdown (default) or index. objectgroup only.
encoding Zeichenkette csv (default) or base64. tilelayer only.
Höhe Ganzzahl (int) Row count. Same as map height for fixed-size maps.
ID Ganzzahl (int) Incremental id - unique across all layers
image Zeichenkette Image used by this layer. imagelayer only.
Layer Array Array of layers. group only.
Name Zeichenkette Name der dieser Ebene zugeordnet ist
objects Array Array of objects. objectgroup only.
offsetx double Horizontal layer offset in pixels (default: 0)
offsety double Vertical layer offset in pixels (default: 0)
opacity double Wert zwischen 0 und 1
properties Array Array of Properties
startx Ganzzahl (int) X coordinate where layer content starts (for infinite maps)
starty Ganzzahl (int) Y coordinate where layer content starts (for infinite maps)
transparentcolor Zeichenkette Hex-formatted color (#RRGGBB) (optional). imagelayer only.
Typ Zeichenkette tilelayer, objectgroup, imagelayer or group
visible Boolean (wahr/falsch) Whether layer is shown or hidden in editor
Breite Ganzzahl (int) Spaltenanzahl. Selber Wert wie die Kartenbreite für feste Mapgrößen.
x Ganzzahl (int) Horizontal layer offset in tiles. Always 0.
y Ganzzahl (int) Vertical layer offset in tiles. Always 0.

Tile Layer Example

{
  "data":[1, 2, 1, 2, 3, 1, 3, 1, 2, 2, 3, 3, 4, 4, 4, 1],
  "height":4,
  "name":"ground",
  "opacity":1,
  "properties":[
    {
      "name":"tileLayerProp",
      "type":"int",
      "value":1
    }],
  "type":"tilelayer",
  "visible":true,
  "width":4,
  "x":0,
  "y":0
}

Object Layer Example

{
  "draworder":"topdown",
  "height":0,
  "name":"people",
  "objects":[ ],
  "opacity":1,
  "properties":[
    {
      "name":"layerProp1",
      "type":"string",
      "value":"someStringValue"
    }],
  "type":"objectgroup",
  "visible":true,
  "width":0,
  "x":0,
  "y":0
}

Chunk

Chunks are used to store the tile layer data for infinite maps.

Feld Type Description
Daten array or string Array of unsigned int (GIDs) or base64-encoded data
Höhe Ganzzahl (int) Height in tiles
Breite Ganzzahl (int) Width in tiles
x Ganzzahl (int) X coordinate in tiles
y Ganzzahl (int) Y coordinate in tiles

Chunk Example

{
  "data":[1, 2, 1, 2, 3, 1, 3, 1, 2, 2, 3, 3, 4, 4, 4, 1, ...],
  "height":16,
  "width":16,
  "x":0,
  "y":-16,
}

Objekt

Feld Type Description
ellipse Boolean (wahr/falsch) Used to mark an object as an ellipse
gid Ganzzahl (int) Global tile ID, only if object represents a tile
Höhe double Height in pixels.
ID Ganzzahl (int) Incremental id, unique across all objects
Name Zeichenkette String assigned to name field in editor
Punkt Boolean (wahr/falsch) Used to mark an object as a point
polygon Array Array of Points, in case the object is a polygon
polyline Array Array of Points, in case the object is a polyline
properties Array Array of Properties
rotation double Angle in degrees clockwise
template Zeichenkette Reference to a template file, in case object is a template instance
text Text Only used for text objects
Typ Zeichenkette String assigned to type field in editor
visible Boolean (wahr/falsch) Whether object is shown in editor.
Breite double Width in pixels.
x double X coordinate in pixels
y double Y coordinate in pixels

Object Example

{
  "gid":5,
  "height":0,
  "id":1,
  "name":"villager",
  "properties":[
    {
      "name":"hp",
      "type":"int",
      "value":12
    }],
  "rotation":0,
  "type":"npc",
  "visible":true,
  "width":0,
  "x":32,
  "y":32
}

Ellipse Example

{
  "ellipse":true,
  "height":152,
  "id":13,
  "name":"",
  "rotation":0,
  "type":"",
  "visible":true,
  "width":248,
  "x":560,
  "y":808
}

Rectangle Example

{
  "height":184,
  "id":14,
  "name":"",
  "rotation":0,
  "type":"",
  "visible":true,
  "width":368,
  "x":576,
  "y":584
}

Point Example

{
  "point":true,
  "height":0,
  "id":20,
  "name":"",
  "rotation":0,
  "type":"",
  "visible":true,
  "width":0,
  "x":220,
  "y":350
}

Polygon Example

{
  "height":0,
  "id":15,
  "name":"",
  "polygon":[
  {
    "x":0,
    "y":0
  },
  {
    "x":152,
    "y":88
  },
  {
    "x":136,
    "y":-128
  },
  {
    "x":80,
    "y":-280
  },
  {
    "x":16,
    "y":-288
  }],
  "rotation":0,
  "type":"",
  "visible":true,
  "width":0,
  "x":-176,
  "y":432
}

Polyline Example

{
  "height":0,
  "id":16,
  "name":"",
  "polyline":[
  {
    "x":0,
    "y":0
  },
  {
    "x":248,
    "y":-32
  },
  {
    "x":376,
    "y":72
  },
  {
    "x":544,
    "y":288
  },
  {
    "x":656,
    "y":120
  },
  {
    "x":512,
    "y":0
  }],
  "rotation":0,
  "type":"",
  "visible":true,
  "width":0,
  "x":240,
  "y":88
}

Text Example

{
  "height":19,
  "id":15,
  "name":"",
  "text":
  {
    "text":"Hello World",
    "wrap":true
  },
  "rotation":0,
  "type":"",
  "visible":true,
  "width":248,
  "x":48,
  "y":136
}

Text

Feld Type Description
bold Boolean (wahr/falsch) Whether to use a bold font (default: false)
color Zeichenkette Hex-formatted color (#RRGGBB or #AARRGGBB) (default: #000000)
fontfamily Zeichenkette Font family (default: sans-serif)
halign Zeichenkette Horizontal alignment (center, right, justify or left (default))
italic Boolean (wahr/falsch) Whether to use an italic font (default: false)
kerning Boolean (wahr/falsch) Whether to use kerning when placing characters (default: true)
pixelsize Ganzzahl (int) Pixel size of font (default: 16)
strikeout Boolean (wahr/falsch) Whether to strike out the text (default: false)
text Zeichenkette Text
underline Boolean (wahr/falsch) Whether to underline the text (default: false)
valign Zeichenkette Vertical alignment (center, bottom or top (default))
wrap Boolean (wahr/falsch) Whether the text is wrapped within the object bounds (default: false)

Tileset

Feld Type Description
backgroundcolor Zeichenkette Hex-formatierte Farbe (#RRGGBB or #AARRGGBB) (optional)
columns Ganzzahl (int) The number of tile columns in the tileset
firstgid Ganzzahl (int) GID corresponding to the first tile in the set
grid Grid (optional)
image Zeichenkette Image used for tiles in this set
imageheight Ganzzahl (int) Height of source image in pixels
imagewidth Ganzzahl (int) Width of source image in pixels
margin Ganzzahl (int) Buffer between image edge and first tile (pixels)
Name Zeichenkette Name given to this tileset
properties Array Array of Properties
source Zeichenkette The external file that contains this tilesets data
spacing Ganzzahl (int) Spacing between adjacent tiles in image (pixels)
terrains Array Array of Terrains (optional)
tilecount Ganzzahl (int) The number of tiles in this tileset
tiledversion Zeichenkette The Tiled version used to save the file
Tile-Höhe Ganzzahl (int) Maximum height of tiles in this set
tileoffset Tile Offset (optional)
tiles Array Array of Tiles (optional)
Tile-Breite Ganzzahl (int) Maximum width of tiles in this set
transparentcolor Zeichenkette Hex-formatted color (#RRGGBB) (optional)
Typ Zeichenkette tileset (for tileset files, since 1.0)
Version Nummer Die JSON-formatierte Version
wangsets Array Array of Wang sets (since 1.1.5)

Each tileset has a firstgid (first global ID) property which tells you the global ID of its first tile (the one with local tile ID 0). This allows you to map the global IDs back to the right tileset, and then calculate the local tile ID by subtracting the firstgid from the global tile ID. The first tileset always has a firstgid value of 1.

Grid

Specifies common grid settings used for tiles in a tileset. See <grid> in the TMX Map Format.

Feld Type Description
Höhe Ganzzahl (int) Cell height of tile grid
Ausrichtung Zeichenkette orthogonal (default) or isometric
Breite Ganzzahl (int) Cell width of tile grid

Tile Offset

See <tileoffset> in the TMX Map Format.

Feld Type Description
x Ganzzahl (int) Horizontal offset in pixels
y Ganzzahl (int) Vertical offset in pixels (positive is down)

Tileset Example

{
 "columns":19,
 "firstgid":1,
 "image":"..\/image\/fishbaddie_parts.png",
 "imageheight":480,
 "imagewidth":640,
 "margin":3,
 "name":"",
 "properties":[
   {
     "name":"myProperty1",
     "type":"string",
     "value":"myProperty1_value"
   }],
 "spacing":1,
 "tilecount":266,
 "tileheight":32,
 "tilewidth":32
}

Tile (Definition)

Feld Type Description
animation Array Array of Frames
ID Ganzzahl (int) Local ID of the tile
image Zeichenkette Image representing this tile (optional)
imageheight Ganzzahl (int) Height of the tile image in pixels
imagewidth Ganzzahl (int) Width of the tile image in pixels
objectgroup Ebene Layer with type objectgroup, when collision shapes are specified (optional)
probability double Percentage chance this tile is chosen when competing with others in the editor (optional)
properties Array Array of Properties
terrain Array Index of terrain for each corner of tile (optional)
Typ Zeichenkette The type of the tile (optional)

A tileset that associates information with each tile, like its image path or terrain type, may include a tiles array property. Each tile has an id property, which specifies the local ID within the tileset.

For the terrain information, each value is a length-4 array where each element is the index of a terrain on one corner of the tile. The order of indices is: top-left, top-right, bottom-left, bottom-right.

Example:

"tiles":[
  {
    "id":0,
    "properties":[
      {
        "name":"myProperty1",
        "type":"string",
        "value":"myProperty1_value"
      }],
    "terrain":[0, 0, 0, 0]
  },
  {
    "id":11,
    "properties":[
      {
        "name":"myProperty2",
        "type":"string",
        "value":"myProperty2_value"
      }],
    "terrain":[0, 1, 0, 1]
  },
  {
    "id":12,
    "properties":[
      {
        "name":"myProperty3",
        "type":"string",
        "value":"myProperty3_value"
      }],
    "terrain":[1, 1, 1, 1]
  }
]

Frame

Feld Type Description
duration Ganzzahl (int) Frame duration in milliseconds
tileid Ganzzahl (int) Local tile ID representing this frame

Terrain

Feld Type Description
Name Zeichenkette Name of terrain
properties Array Array of Properties
tile Ganzzahl (int) Local ID of tile representing terrain

Example:

"terrains":[
{
  "name":"ground",
  "tile":0
},
{
  "name":"chasm",
  "tile":12
},
{
  "name":"cliff",
  "tile":36
}],

Wang Set

Feld Type Description
cornercolors Array Array of Wang colors
edgecolors Array Array of Wang colors
Name Zeichenkette Name of the Wang set
properties Array Array of Properties
tile Ganzzahl (int) Local ID of tile representing the Wang set
wangtiles Array Array of Wang tiles

Wang Color

Feld Type Description
color Zeichenkette Hex-formatted color (#RRGGBB or #AARRGGBB)
Name Zeichenkette Name of the Wang color
probability double Probability used when randomizing
tile Ganzzahl (int) Local ID of tile representing the Wang color

Example:

{
  "color": "#d31313",
  "name": "Rails",
  "probability": 1,
  "tile": 18
}

Wang Tile

Feld Type Description
dflip Boolean (wahr/falsch) Tile is flipped diagonally (default: false)
hflip Boolean (wahr/falsch) Tile is flipped horizontally (default: false)
tileid Ganzzahl (int) Local ID of tile
vflip Boolean (wahr/falsch) Tile is flipped vertically (default: false)
wangid Array Array of Wang color indexes (uchar[8])

Example:

{
  "dflip": false,
  "hflip": false,
  "tileid": 0,
  "vflip": false,
  "wangid": [2, 0, 1, 0, 1, 0, 2, 0]
}

Object Template

An object template is written to its own file and referenced by any instances of that template.

Feld Type Description
Typ Zeichenkette template
tileset Tileset External tileset used by the template (optional)
object Objekt The object instantiated by this template

Property

Feld Type Description
Name Zeichenkette Name of the property
Typ Zeichenkette Type of the property (string (default), int, float, bool, color or file (since 0.16, with color and file added in 0.17))
value value Value of the property

Point

A point on a polygon or a polyline, relative to the position of the object.

Feld Type Description
x double X coordinate in pixels
y double Y coordinate in pixels

Changelog

Tiled 1.2

  • Added nextlayerid to the Karte object.
  • Added id to the Ebene object.
  • The tiles in a Tileset are now stored as an array instead of an object. Previously the tile IDs were stored as string keys of the „tiles“ object, now they are stored as id property of each Tile object.
  • Custom tile properties are now stored within each Tile instead of being included as tileproperties in the Tileset object.
  • Custom properties are now stored in an array instead of an object where the property names were the keys. Each property is now an object that stores the name, type and value of the property. The separate propertytypes and tilepropertytypes attributes have been removed.

Tiled 1.1