You’ve modeled your data exactly how it should be, and everything’s working fine.
Now it’s time to finish your JSON Decoder, but certain fields are strings where in your Elm code they’re complex data types!
This happens most often with dates, but tagged unions have this problem too.
In 0.17 we had
customDecoder, which could turn any
Result String a into a
Decoder a, but it went away in 0.18.
So… what do we do?
You know how it takes so much effort to produce even the simplest of programs when JSON parsing is involved?
Wouldn’t it be nice if you could breeze right on by that step and get on with writing your business logic?
This is what you’ll get with The JSON Survival Kit, a short ebook on JSON decoding in Elm.
You’ll learn how to piece the JSON decoder API together in a way that works for your situation so you can get back to solving your problems.
Get step-by-step instructions for avoiding boilerplate, write decoders so adapting to new data is a breeze, and finally understand why the time and effort is worth it (hint: it so is.)
Never get stuck on JSON Decoding again!
Adding and changing new fields in your JSON API is just a part of life.
We’ve got to have ways to deal with that!
In Elm, it’s easy to add new fields with
Let’s do it!
When you’re writing JSON decoders, it’s helpful to understand what’s going on.
When you’re up in the clouds with your JSON workflow doing all sorts of fancy and advanced stuff, it’s great!
But what about when you don’t need all the fancy stuff?
(Or you’re just getting started?)
It’s a hassle to write decoders, objects, and encoders for every single field by hand.
It feels like tedious boilerplate.
But really, you don’t have to do it all by hand.
Please meet JSON to Elm.