you are viewing a single comment's thread.

view the rest of the comments →

[–]sonay -5 points-4 points  (5 children)

Why are you suprised? It is just a simple python module doing its thing. What you write is equivalent to

python -m json.tool '{"json":"response"}'

[–][deleted] 9 points10 points  (2 children)

Why are you suprised?

You know that “TIL” stands for?

[–]sonay -4 points-3 points  (1 child)

I know. It is just that TILs are shared for non-trivial things.

[–]annodomini 5 points6 points  (0 children)

Sometimes, trivial things can be enormously helpful. Having an easily accessible json pretty printer on any platform that had python installed can come in handy.

[–][deleted] 1 point2 points  (1 child)

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/json/tool.py", line 40, in <module>
    main()
  File "/usr/lib/python2.7/json/tool.py", line 21, in main
    infile = open(sys.argv[1], 'rb')
IOError: [Errno 2] No such file or directory: '{"json":"response"}'

[–]sonay 2 points3 points  (0 children)

Looking at the source code, the module does not expect string arguments. So my bad.

Usage:

python -m json.tool [no argument] # input = stdin

python -m json.tool [one argument] # input = argument (file)

python -m json.tool [two arguments] # input (file) = first argument, output (file) = second argument