print json python

import json

uglyjson = '{"firstnam":"James","surname":"Bond","mobile":["007-700-007","001-007-007-0007"]}'

#json.load method converts JSON string to Python Object
parsed = json.loads(uglyjson)

print(json.dumps(parsed, indent=2, sort_keys=True))

Here is what the above code is Doing:
1. We have a string containing a JSON object.
2. We use the json.loads() method to convert the string to a Python dictionary.
3. We use the json.dumps() method to convert the dictionary to a JSON string.
4. We pass the json.dumps() method four arguments.
a. The dictionary we want to convert to JSON.
b. The indent argument tells the method how many spaces to use for indentation.
c. The sort_keys argument tells the method whether it should sort the keys in the dictionary.
d. The separators argument tells the method what to use to separate the keys and values.