How to see a large JSON file pretty printed on Ubuntu?

JJD picture JJD · May 22, 2012 · Viewed 50.1k times · Source

I would like to hear your suggestions on how to handle a large (40MB) JSON file on Ubuntu. I would like to see it pretty printed in vim or gedit or any other editor. One can find numerious tutorials on how to prettify the JSON, however, they do not have to deal with large input. I also imagine I could pipe the data through pygments or any other syntax highlighter. I am curious to hearing your ideas.

Example download:

wget -O large-dataset.json http://data.wien.gv.at/daten/wfs?service=WFS&request=GetFeature&version=1.1.0&typeName=ogdwien:BAUMOGD&srsName=EPSG:4326&outputFormat=json

Please mind the download size!


EDIT: I found out that meld is working somewhat. The application does not load the whole file at once which would block the user interface. Instead it sequentially reads the file content.

Answer

gertvdijk picture gertvdijk · Sep 19, 2017

Python JSON's module can do this too (python -m json.tool), e.g.:

cat myjsonfile.json | python -m json.tool > pretty.json