getto-systems/elm-json/1.0.0

Getto.Json.SafeDecode

json utilities

value |> SafeDecode.at ["name"]    (SafeDecode.string "")
value |> SafeDecode.at ["age"]     (SafeDecode.string 0)
value |> SafeDecode.at ["isValid"] (SafeDecode.bool False)


value |> SafeDecode.at ["roles"] (SafeDecode.list (SafeDecode.string ""))


obj |> SafeDecode.valueAt ["object"]

Definition

type Decoder a

decoder and default value

Decoders

string : String -> Decoder String

string safe decoder

int : Int -> Decoder Int

int safe decoder

bool : Bool -> Decoder Bool

bool safe decoder

list : Decoder a -> Decoder (List a)

list safe decoder

Decode

at : List String -> Decoder a -> Value -> a

decode from json value with safe decoder

valueAt : List String -> Value -> Value

decode to json value