I'm trying to iterate over a .json file with a small script to find a attribute named 'model' and change it's value on each object. (It's a db-dump from Django).
import codecs, json
data = ""
with codecs.open("dump2.json", 'r', 'utf8') as data_file:
data = json.load(data_file)
for i in data:
for key in i:
if key[0] == 'model':
key[1] = "app.model" #not working
with codecs.open('dump2.json', 'w', 'utf8') as f:
json.dump(data, f)
What am I doing wrong here? I don't get any errors. And values are not changed.
dataoriorkeyor anything else for that matter is? How do you think we would be able to advice what is going wrong?