What are you trying to do? It looks like you're encoding what is basically a Dict: http://package.elm-lang.org/packages/elm-lang/core/4.0.4/Dict
If you use a dict, the Json.Decode.Dict function is probably what you want: http://package.elm-lang.org/packages/elm-lang/core/4.0.4/Json-Decode#dict If, for some reason, you need your values in the exact format that you've specified, you could apply this function to the dict you get from Json.Decode.dict. (\d -> d |> Dict.toList |> map (\ (x,y) -> {name : x, value : y}) ) But I suspect that just keeping them as a Dict is better suited to what you want. On Fri, Aug 5, 2016 at 8:44 AM, Petr Huřťák <[email protected]> wrote: > 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]. > 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.
