python write pretty json code example
Example 1: print json python
import json
uglyjson = '{"firstnam":"James","surname":"Bond","mobile":["007-700-007","001-007-007-0007"]}'
parsed = json.loads(uglyjson)
print(json.dumps(parsed, indent=2, sort_keys=True))
Example 2: pretty json python
print(json.dumps(dict, indent=4))
Example 3: python json.dumps pretty print
json.dumps(x, indent=4)
Example 4: how to print a json file in python
import json
f = open('data.json',)
data = json.load(f)
for i in data['emp_details']:
print(i)
f.close()