Reading a JSON file
JavaScript Object Notation (JSON) is a semi-structured data format. Some articles also define JSON as an unstructured data format, but the truth is this format can be used for multiple purposes.
JSON structure uses nested objects and arrays and, due to its flexibility, many applications and APIs use it to export or share data. That is why describing this file format in this chapter is essential.
This recipe will explore how to read a JSON file using a built-in Python library and explain how the process works.
Note
JSON is an alternative to XML files, which are very verbose and require more coding to manipulate their data.
Getting ready
This recipe is going to use the GitHub Events JSON data, which can be found in the GitHub repository of this book at https://github.com/jdorfman/awesome-json-datasets with other free JSON data.
To retrieve the data, click on GitHub API | Events, copy the content from the page, and save it as a .
json
file...