python function to write json file
import json
def write_json_data(data, filename):
with open('{}.json'.format(filename), 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=4)