how to write data into a json file code example
Example 1: json dump to file
import json
data = {"key": "value"}
with open('data.json', 'w') as jsonfile:
json.dump(data, jsonfile)
Example 2: write json pythonb
>>> jstr = json.dumps(data, ensure_ascii=False, indent=4)
>>> print(jstr)
{
"item": "Beer",
"cost": "£4.00"
}