justgook / elm-tiled / Tiled.Extra.Property

Nested way to represent custom properties.


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

Custom nested properties

convert : Tiled.Properties.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

values : Property -> List Property

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