Before we look at how to deal with JSON, let’s take a second to understand what it is (and what it isn’t).
There are two ways data can be stored in JSON:
When receiving data from a web server, the data is always a string, which means that it’s your job to convert it into a data structure you can work with.
If you’d like to find out more about how JSON works, please visit the JSON website.
In the following examples, we’ll use the fantastic icanhazdadjoke API. As you can read in its documentation, making a GET request where the
Accept header is set to
application/json will see the API return a JSON payload.