Mastering Python: Part 2: Working with JSON

Learning Python

Using Python

Mastering Python

Python is a general-purpose interpreted programming language. It emphasizes readability through the use of whitespace and supports multiple programming paradigms such as functional and object-oriented models.

Working with JSON

Used as early as 1999 in web development, the JavaScript Object Notation (JSON) has now become a language-independent notation most commonly used as part of a communication layer between programs and web services.

JSON in Python

As a modern programming language, Python also supports JSON through its json module.


Most JSON work concern two functions in Python: load() and dump().

The first, load(), takes a file object (such as returned through using open() ) and will read the entire file into memory as JSON. The second, dump(), shows the JSON data in a human-readable way.

As a Dictionary

Complex JSON data is usually loaded as a Dictionary in Python. As objects and ordered sets, the data can be accessed through its structure using either key-value pairs (Dictionary) or the position (List) of the data.

Play with the example on!