python json format file code example
Example 1: save json file python
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
Example 2: how to print a json file in python
# Python program to read
# json file
import json
# Opening JSON file
f = open('data.json',)
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data['emp_details']:
print(i)
# Closing file
f.close()
Example 3: python format json file
python3 -m json.tool unformatted.json > formatted.json