Skip to content

Instantly share code, notes, and snippets.

@JoelQ
Last active January 5, 2018 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoelQ/d64b0db11cd07e71030dd9b5e399fc6a to your computer and use it in GitHub Desktop.
Save JoelQ/d64b0db11cd07e71030dd9b5e399fc6a to your computer and use it in GitHub Desktop.

Real World JSON

The real world is messy and servers are no exception. The data we get is inconsistent, oddly-shaped, and sometimes flat-out wrong. Elm's JSON decoders give us the tools to deal with all of these scenarios and more.

The world beyond the nicely contrived examples of decoding tutorials is riddled with challenges such as decoding union types, conditional decoding, and handling bad data. Join me as we attempt to decode data into something our Elm apps can work with in a series of real-world examples. Along the way, we'll level up your JSON skills till you're slinging decoders around that can convert anything the server wants to throw at you!

Details

Most JSON decoding tutorials cover how to decode records but in real life you often want to decode to something more complex like union types or just get weird data thrown at you. I want to cover a bunch of these situations and how to deal with them.

I trialled this talk at the November 2017 elm-remote-meetup and got a good response. I also published some scenarios and solutions in blog post form at https://robots.thoughtbot.com/5-common-json-decoders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment