title | description | author | tags |
---|---|---|---|
Write JSON File |
Writes a dictionary to a JSON file. |
e3nviction |
json,file,write |
import json
def write_json(filepath, data):
with open(filepath, 'w') as file:
json.dump(data, file, indent=4)
# Usage:
data = {'name': 'John', 'age': 30}
write_json('data.json', data)