json save data code example
Example 1: read json file python
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
flx = json.dumps(data, ensure_ascii=False, indent=4)
print(flx)
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"
}
]
}