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

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

print(a)

with open('data.json', 'w') as fh:
    json.dump(a, fh)
{'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)

As a special case dump will save the string in a file or in other stream.