Skip to content

Instantly share code, notes, and snippets.

@SecurityForUs
Created June 21, 2013 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SecurityForUs/5831700 to your computer and use it in GitHub Desktop.
Save SecurityForUs/5831700 to your computer and use it in GitHub Desktop.
try:
import json
except ImportError:
import simplejson # Python 2.6 support
data = {'some' : 'data', 'goes' : 'here'}
# To dump data as JSON (might have to append ,"w" to the filename)
with open("/home/bob/.prog_settings") as fp:
fp.write(json.dumps(data))
# To read data back as JSON (might have to append ,"r" to the filename)
with open("/home/bob/.prog_settings") as fp:
data = json.loads(fp.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment