Combine the answer of @mgilson and @gnibbler, I found what I need was this:
d = {"name":"interpolator",
"children":[{'name':key,"size":value} for key,value in sample.items()]}
j = json.dumps(d, indent=4)
f = open('sample.json', 'w')
print >> f, j
f.close()
It this way, I got a pretty-print json file.
The tricks print >> f, j
is found from here:
http://www.anthonydebarros.com/2012/03/11/generate-json-from-sql-using-python/