justgook/elm-tiled/3.0.1

NOTE: the latest version is 3.0.2

Tiled.Extra.Property

Nested way to represent custom properties.

= Bool Bool
| Int Int
| Float Float
| String String
| Color String
| File String
| Object Int
| Group (Dict String Property)

Custom nested properties

convert : Properties -> Property

Convert Tiled.Properties to Tiled.Extra.Property all properties that have name.subName or name[subName] is grouped as Group with nested properties of subName.

Example:

{
  "prop1.a": 1,
  "prop1.b": 2,
  "prop1[c]": 3,
  "prop2.a": 4
}

become:

{
  "prop1": {
    "a": 1,
    "b": 2,
    "c": 3
  },
  "prop2": {
    "a": 4
  }
}
get : String -> Property -> Maybe Property

Get deep property:

Property.get "a.b.c.d" prop
at : List String -> Property -> Maybe Property

Same as get but path is List of keys

Property.get [ "a", "b", "c", "d" ] prop

Convert Group to List of its values, or get list of single Property

toList : Property -> List ( String, Property )

Convert Group to List of key-value pairs