I've been playing around with Python for a few months now, but I'm stuck on one issue specially with adding a new key to an existing list
Here's my existing JSON data:
{"ID": 384903848394829, "Items": [{"Apples" : 10, "Bananas" : 5, "Orange" : 15}]}
Then, I want to add an item to the "Items" list, so then it would look something like this:
{"ID": 384903848394829, "Items": [{"Apples" : 10, "Bananas" : 5, "Orange" : 15, "Peach" : 2}]}
Here's what I've got so far:
import json
jsonFile = open(file)
jsonLoad = json.load(jsonFile)
fruitToAdd = {"Peach" : 2}
// Not quite sure what to put here
dump = json.dumps(jsonLoad, indent=4)
file.write(dump)
file.close()