NOTE: this package is not compatible with Elm 0.19.1
Convenience functions for turning Elm values into Json values.
Turn a Dict into a JSON object.
Dict
import Json.Encode exposing (..) import Dict Dict.fromList [ ( "Sue", 38 ), ( "Tom", 42 ) ] |> dict identity int |> encode 0 --> """{"Sue":38,"Tom":42}"""
Encode a Maybe value. If the value is Nothing it will be encoded as null
Nothing
null
import Json.Encode exposing (..) maybe int (Just 50) --> int 50 maybe int Nothing --> null
Turn a
Dictinto a JSON object.