Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829module Json.Decode.Ext exposing (listIgnore, optionalField)
import Json.Decode as Decode exposing (Decoder)import Maybe.Extra as Maybe
-- 🔱
{-| A list decoder that always succeeds, throwing away the failures.-}listIgnore : Decoder a -> Decoder (List a)listIgnore decoder = decoder |> Decode.maybe |> Decode.list |> Decode.map Maybe.values
{-| Provide a default value for a field that might not be there.-}optionalField : String -> Decoder a -> a -> Decoder aoptionalField field decoder defaultValue = decoder |> Decode.field field |> Decode.maybe |> Decode.map (Maybe.withDefault defaultValue)