The name of the field in the Elm record does not need to match the name of the field in the JSON, so you can fix the code generated by json-to-elm by renaming the "1Sa" field in the type alias to something that doesn't start with a number.
On Thu, Dec 29, 2016 at 8:28 PM, Jaroslaw Zabiello <[email protected]> wrote: > How to decode/encode JSON object which has some keys starting as a number? > Eg: > > { > "1Sa": { > "name": "1Sm", > "label": "1 Samuela" > }, > "Ezr": { > "name": "Ezd", > "label": "Ezdrasza" > } > } > > The code generated by http://noredink.github.io/json-to-elm/ is *invalid* > because Elm's Record cannot habe key name started with the number. :( > > type alias Books = > { *1Sa* : Books1Sa > , ezr : BooksEzr > } > > -- > 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.
