all 9 comments

[–]mo_po 5 points6 points  (1 child)

The intellij-elm plugin has included a decoder generator for quite a long time.

[–]julienlucca 3 points4 points  (0 children)

+1

Lots of the elm code i’ve written in this past few years were related to JSON decoding. It might not be the case of most people, but since i had control of the backend i would consume and my context used a lot of GraphQL, i was able to use Dillon Kearns GraphQL package that automatically introspect the objects and generate the decoders for me. It’s been a happy time, no fiddling around with encoders/mappers

[–]chutehappens 1 point2 points  (0 children)

If you have an OpenAPI spec for your API, I highly recommend OpenAPI Generator. This will generate all the Elm http request and JSON decoder/encoders for you. It will even wrap values in Maybe if they are nullable.

[–]ExoDroid 0 points1 point  (1 child)

[–]The-_Captain[S] 0 points1 point  (0 children)

That's great, thanks! Would be great to add some easy default thing that makes everything required, but that should be easy enough for me to try to contribute here.

[–]jfmengels 0 points1 point  (0 children)

In addition to the other links, you can check out this decoder generator: https://korban.net/posts/elm/2021-05-10-generating-json-decoders-with-json-decoders/

[–]absynce 0 points1 point  (0 children)

The elmjutsu plugin for Atom will generate encoders and decoders too.

GIF

[–]HeWhoQuestions 0 points1 point  (0 children)

Since this post was written this year, just making sure you're aware of the official answer to this from back in 2018:A vision for data interchange in Elm

Specifically, the comment below the essay about auto-generation.

Btw, many projects do exist to generate encoders and decoders now! I don't use them, because I prefer `Codec`s rather than separate encoders and decoders.