Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 881 Bytes

README.md

File metadata and controls

37 lines (29 loc) · 881 Bytes

Elm Edn Decode

This library provides decoders for the edn type exposed by edn-parser

The API quite closely follows the API of the standard elm/json library, with a few noticeable changes due to the very different natures of edn and json

You will likely want to use this library in conjunction with edn-parser as the Edn type constructor is required to query fields in edn maps.

import Edn exposing (..)
import Edn.Decode exposing (..)

type alias Person =
    { name : String
    , age : Int
    }

personDecoder = 
    decodeString
        (map2
            Person
            (keyAt (EdnString "name") string)
            (keyAt (EdnString "age") int)
        )

rawEdn = """
    { "name" "Tony"
    , "age" 32
    }
"""

result = decodeString personDecoder rawEdn