Calling json.tool from the command line to pretty-print JSON output
suggest changeGiven some JSON file “foo.json” like:
{"foo": {"bar": {"baz": 1}}}
we can call the module directly from the command line (passing the filename as an argument) to pretty-print it:
$ python -m json.tool foo.json
{
"foo": {
"bar": {
"baz": 1
}
}
}
The module will also take input from STDOUT, so (in Bash) we equally could do:
$ cat foo.json | python -m json.tool
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents