You will at some point encounter JSON data.
It is the most widely used format for communication and transmission.
There are two ways to read a JSON file that I use most of the time.
It really depends on the structure of the file.
Reading JSON with the JSON library
When I encounter a JSON file that looks like this and is a straight dictionary, I use the JSON library like so
Reading JSON with pandas library
You might encounter other JSON-like formats, like a JSON file containing a list of records. This is often the case when dealing with APIs.
Such file would look like this :
Then I would read it like so
Here you are! You are now an expert at reading JSON files.
This can also be applied when you deal with APIs data !