I have written the following python code to populate a JSON file.
import json
data = {}
data['people'] = []
for i in range(0,3):
data['people'].append({
'name': 'C%d'%(i),
'div':i,
'from': 'City%d'%(i)
})
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
However, my JSON file looks something like this:
{"people": [{"div":0,"from":,"City0":"name":"C0"},{"div":0,"from":,"City0":"name":"C0"}]}
My order of input is different from the output's. What is the reason and how do I rectify this?