Parsing JSON in Shortcuts from an API request
If you look at the Dark Sky API response, you can see that there’s a lot of data stored in JSON. While it’s not easy to read at first, over time you’ll start to recognise the structures in JSON data, as well as how to identify dictionaries, lists, keys and values. Often, developers include a nicely formatted version of the JSON data that their API will return, so look for that in their documentation. Additionally, it’s helpful to check your work using services like the online JSON Editor.
Notice that the top-level object is a dictionary with the keys
minutely. Some of these keys, such as
timezone, simply contain a number or text value, but others, such as
daily, have a dictionary value.
daily dictionary contains some keys with values that are simple text, such as the
Rain throughout the day. But others, such as
data, are lists containing a forecast (represented by a dictionary) for each hour.