This works, thanks for help On Friday, August 5, 2016 at 5:52:07 PM UTC+2, Janis Voigtländer wrote: > > Untested, but probably works: > > decoder = Json.Decode.dict Json.Decode.string |> Json.Decode.map (Dict.toList > >> List.map (\(name,value) -> Config name value)) > > > > 2016-08-05 17:44 GMT+02:00 Petr Huřťák <[email protected] <javascript:>>: > >> Hi, >> >> I have JSON from API with following data structure >> >> { >> "configurations": { >> "configName1": "configValue1", >> "configName2": "configValue2", >> "configName2": "configValue3" >> } >> } >> >> >> >> How do I construct Decoder which outputs data structure which is little >> easier to work with in elm, like following: >> >> type alias Configs = List Config >> >> type alias Config = >> { name : String >> , value : String >> } >> >> >> >> which would result with following Elm data structure >> >> configs : Configs >> configs = >> [ { name: "configName1", value: "configValue1" } >> , { name: "configName2", value: "configValue2" } >> , { name: "configName3", value: "configValue3" } >> ] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Elm Discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > >
-- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
