how write json file python code example
Example 1: save json file python
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
Example 2: write json pythonb
>>> import json
>>> data = {'people':[{'name': 'Scott', 'website': 'stackabuse.com', 'from': 'Nebraska'}]}
>>> json.dumps(data, indent=4)
{
"people": [
{
"website": "stackabuse.com",
"from": "Nebraska",
"name": "Scott"
}
]
}