11.6 Reading JSON and YAML documents
JavaScript Object Notation (JSON) is often used for serializing data. For details, see http://json.org. Python includes the json module in order to serialize and deserialize data in this notation.
JSON documents are used widely by web applications. It’s common to exchange data between RESTful web clients and servers using documents in JSON notation. These two tiers of an application stack communicate via JSON documents sent via the HTTP protocol.
The YAML format is a more sophisticated and flexible extension to JSON notation. For details, see https://yaml.org. Any JSON document is also a valid YAML document. The reverse is not true: YAML syntax is more complex and includes constructs that are not valid JSON.
To use YAML, an additional module has to be installed:
(cookbook3) % python -m pip install pyyaml
The PyYAML project offers a yaml module that is popular and works well. See https://pypi.org...