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 recognize 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. Ezenfelül érdemes ellenőrizni a munkáját olyan szolgáltatásokkal, mint az online JSON-szerkesztő.
Notice that the top-level object is a dictionary with the keys latitude
, longitude
, timezone
, currently
, and minutely
. Some of these keys, such as latitude
and timezone
, simply contain a number or text value, but others, such as daily
, have a dictionary value.
And the daily
dictionary contains some keys with values that are simple text, such as the summary
, with Rain throughout the day
. Azonban az egyebek, például az adatok
olyan listák, amelyek előrejelzést (amelyet egy szótár jelöl) tartalmaznak minden órához.