json.dump()
takes two arguments, the Python object to dump and the file to write it to.
Make your changes first, then after the loop, re-open the file for writing and write out the whole data
object:
with open("app.json") as json_data:
data = json.load(json_data)
for d in data['employees']:
d['history'].append({'day': 01.01.15, 'historyId': 44, 'time': 12.00})
with open("app.json", 'w') as json_data:
json.dump(data, json_data)
This essentially replaces the file contents with the JSON-serialised new data structure.
solved Writing JSON in Python