JSON
JavaScript Object Notation (JSON) is a standard way of representing simple objects, such as lists and dicts, in the form of text strings. Although, it was originally developed for JavaScript, JSON is language independent and most languages can work with it. It's lightweight, yet flexible enough to handle a broad range of data. This makes it ideal for exchanging data over HTTP, and a large number of web APIs use this as their primary data format.
Encoding and decoding
We use the json module for working with JSON in Python. Let's create a JSON representation of a Python list by using the following commands:
>>> import json >>> l = ['a', 'b', 'c'] >>> json.dumps(l) '["a", "b", "c"]'
We use the json.dumps() function for converting an object to a JSON string. In this case, we can see that the JSON string appears to be identical to Python's own representation of a list, but note...