The json Module
Usage
Writing JSON
import json
person = {
"first_name": "Ophelia",
"last_name": "Clarke",
"message": "Hi, thanks for the ice cream!",
"fav_flavors": ["Vanilla Bean", "Mocha", "Strawberry"]
}
raw_data = json.dumps(person)
print(type(raw_data)) #> <class 'str'>
print(raw_data) #> '{"first_name": "Ophelia", "last_name": "Clarke", "message": "Hi, thanks for the ice cream!", "fav_flavors": ["Vanilla Bean", "Mocha", "Strawberry"]}'Reading JSON
Reading and Writing JSON Files
Last updated