July 2019
Intermediate to advanced
310 pages
7h 26m
English
Prior to this point, you’ve been able to stay safely within the confines of Elm’s magical world of static types. However, you’re going to run into an interesting dilemma if you want to accept an arbitrary JSON payload from a server. Elm doesn’t have a JSON.parse function like JavaScript because it can’t dynamically create records like JavaScript can create objects. In this section, you’re going to learn about JSON decoders, why they’re important, and how to use them to safely convert JSON into a static type Elm can use.
To understand why you need JSON decoders, let’s look at a couple of example JSON payloads you could use with your application. Visit https://programming-elm.com/feed/1 in your browser. ...
Read now
Unlock full access