I'm trying to combine two JSON dictionaries. So far I have a JSON file(myjfile.json) with the contents
{"cars": 1, "houses": 2, "schools": 3, "stores": 4}
Also, I have a dictionary(mydict) in Python which looks like this:
{"Pens": 1, "Pencils": 2, "Paper": 3}
When I combine the two, they are two different dictionaries.
with open('myfile.json' , 'a') as f:
json.dump(mydict, f)
Note that the myfile.json is being written with 'a' and a /n in the code because I want to keep the contents of the file and start a new line each time it's being written to.
I want the final result to look like
{"cars": 1, "houses": 2, "schools": 3, "stores": 4, "Pens": 1, "Pencils": 2, "Paper": 3}
a.update(b)for yourdicts?