[issue29636] Specifying indent in the json.tool command

Daniel Himmelstein report at bugs.python.org
Tue Jul 30 09:48:29 EDT 2019


Daniel Himmelstein <daniel.himmelstein at gmail.com> added the comment:

Since opening this issue, I've encountered several additional instances where indentation control would have been nice. I don't agree that jq is a sufficient substitute:

1. jq is generally not pre-installed on systems. For projects where users are guaranteed to have Python installed (but may be on any operating system), it is most straightforward to be able to just use a python command and not have to explain how to install jq on 3 different OSes.

2. jq does a lot more than prettifying JSON. The simple use case of reformatting JSON (to/from a file or stdin/stdout) can be challenging.

3. json.tool describes itself as a "simple command line interface to ... pretty-print JSON objects". Indentation is an essential aspect of pretty printing. Why even have this CLI if we're unwilling to add essential basic functionality that is already well supported by the underlying json.dump API?

Python excels at APIs that match user needs. It seems like we're a small change away from making json.tool flexible enough to satisfy real-world needs.

So I'm in favor of merging PR 9765 or PR 345. I'm happy to do the work on either to get them mergeable based on whatever specification we can agree on here.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29636>
_______________________________________


More information about the Python-bugs-list mailing list