getto-systems / elm-json / 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 : Basics.Int -> Decoder Basics.Int

int safe decoder

bool : Basics.Bool -> Decoder Basics.Bool

bool safe decoder

list : Decoder a -> Decoder (List a)

list safe decoder

Decode

at : List String -> Decoder a -> Json.Decode.Value -> a

decode from json value with safe decoder

valueAt : List String -> Json.Decode.Value -> Json.Decode.Value

decode to json value