Rodrigo Girão Serrão 🐍🚀 @mathspp.com · Jan 12

You can use the module `json` to read and write data in the JSON format, which is very suitable to represent the most common Python built-in types: - lists - dictionaries - strings - integers - floats - Booleans.

0 likes 2 replies

?

Replies

"Augeas" · Jan 12

Pass the "indent" kwarg to json.dumps and you get *readable* JSON....

Rodrigo Girão Serrão 🐍🚀 · Jan 12

To write data in the JSON format to a file, use the function `json.dump`: ```py import json data = { "name": "Rodrigo", "newsletters": 2, } with open("data.json", "w") as f: json.dump(data, f) ``` The call to `json.dump` writes the JSON data into the file.