format a json file python code example
Example 1: pretty json python
print(json.dumps(dict, indent=4))
Example 2: python format json file
python3 -m json.tool unformatted.json > formatted.json
Example 3: write json pythonb
>>> jstr = json.dumps(data, ensure_ascii=False, indent=4)
>>> print(jstr)
{
"item": "Beer",
"cost": "£4.00"
}