Skip to content

Instantly share code, notes, and snippets.

@nolochemical
Created September 23, 2011 04:07
Show Gist options
  • Save nolochemical/1236732 to your computer and use it in GitHub Desktop.
Save nolochemical/1236732 to your computer and use it in GitHub Desktop.
SimpleJson CRUD
#! /usr/bin/python2
import simplejson as json
def save_profile():
pfile = ".profile" # {'settings':{'clean_cache_close':908}}
pfile_handle = open(pfile, "r+")
preader = pfile_handle.readline()
tmp = json.loads(preader)
tmp['settings']['clean_cache_close'] = 18
print tmp # print the whole json string, save it, whatever
save_profile()
>>>{'settings':{'clean_cache_close':18}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment