import json def write_json(filename, json_data): with open(filename) as f: obj = json.load(f) obj.append(json_data) with open(filename,"w+") as of: json.dump(obj, of)