examples/json/dumps.py
from __future__ import print_function
import json

a = {
  "fname" : 'Foo',
  "lname" : 'Bar',
  "email" : None,
  "children" : [
     "Moo",
     "Koo",
     "Roo"
  ]
}
print(a)

json_str = json.dumps(a) 
print(json_str)

with open('data.json', 'w') as fh:
    fh.write(json_str)
{'lname': 'Bar', 'email': None, 'fname': 'Foo',
  'children': ['Moo', 'Koo', 'Roo']}

{"lname": "Bar", "email": null, "fname": "Foo",
  "children": ["Moo", "Koo", "Roo"]}

(lines were broken for readability on the slides)

dumps can be used to take a Python data structure and generate a string in JSON format. That string can then be saved in a file, inserted in a database, or sent over the wire.