Python writing to a json -


ive been working on address book in python, , need make function can write json file. function needs able add/append specific json layout

json layout example -

{"addresses":          [           {"name": "example", "town": "example", "address": "example"}         ]  } 

the problem - know how write json file, not how write json object...

can please show me example of how add/append json object

json string in python. can load , dump json whenever need return or change respectively. example:

import json   py_dict = {'a': 'b'} # convert dict string json_obj = json.dumps(py_dict) # oops need make change -> convert string dict py_dict = json.loads(json_obj) # append dict py_dict['hello'] = 'world' # convert dict string json_obj = json.dumps(py_dict) 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -