examples/json/round_trip.py
from __future__ import print_function
import json
import os

data = {}
filename = 'mydata.json'

if os.path.exists(filename):
    with open(filename) as fh:
        json_str = fh.read()
        print(json_str)
        data = json.loads(json_str)

data['name'] = 'Foo Bar'

with open(filename, 'w') as fh:
   json_str = json.dumps(data)
   fh.write(json_str)