Python Notes and Examples
 

JSON

Some terminology:

when going from JSON → Python = “load”
when going from Python → JSON = “dump”
import json

# Returns a Python data structure.
vals = json.loads(open('foo.json').read())

data = {
    'name': 'Za',
    'size': 3,
    'age': 1.4,
}

s = json.dumps(data) # Returns a string containing json.

Note, re. JSON vs Python:

null ↔︎ None
true ↔︎ True
false ↔︎ False

About JSON: