Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 398 Bytes

File metadata and controls

20 lines (14 loc) · 398 Bytes

The json Module

Reference: https://docs.python.org/3/library/json.html.

Use json.dumps() to convert a dictionary to JSON:

import json

person = {
    "first": "Santa",
    "last": "Claus",
    "message": "Ho Ho Ho",
    "stops": ["New York", "Denver", "San Francisco"]
}

json.dumps(person)

... or vice-versa using json.loads() to convert a JSON string into a dictionary.