I can't get my json file as "pretty" JSON using iPython

Viewed 1289

I am using from IPython.display import JSON to have an organized json. However, I get the following:

<IPython.core.display.JSON object>

my code:

from IPython.display import JSON
with open("world_bank_projects.json") as f:
    data = json.load(f)

JSON(data)
1 Answers

Don't bother with ipython for JSON pretty-printing, just use the builtin feature known as the indent parameter in json.dumps:

print(json.dumps(data, indent=4, sort_keys=True))
Related