This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dhimmel
Recipients dhimmel, methane, serhiy.storchaka
Date 2017-03-03.19:20:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To recap the discussion from there are three potential mutually exclusive command line options that have been suggested. There are as follows.

import json
obj = [1, 2]

print(json.dumps(obj, indent=4))

print(json.dumps(obj, indent=None))

print(json.dumps(obj, separators=(',', ':')))

which produces the following output:

[1, 2]

Currently, has implemented --indent and --no-indent. One suggestion was to replace --no-indent with --compact, but that would prevent json.tool from outputting YAML < 1.2 compatible JSON. Therefore, the main question is whether to add --compact or not?

There is a clear use case for --compact. However, it requires a bit more "logic" as there is no `compact` argument in json.dump. Therefore @serhiy.storchaka suggests not adding --compact to keep json.tool lightweight.

I disagree that json.tool is "mainly for debugging". I encounter lot's of applications were JSON needs to be reformatted, so I see json.tool as a cross-platform command line utility.

However, I am more concerned that the JSON API may change, especially with respect to the compact encoding (see Therefore, it seems prudent to let the API evolve and later revisit whether a --compact argument makes sense.

The danger of adding --compact now would be if json.dump adopts an argument for --compact that is not compact. Then aligning the json.tool and json.dump terminology could require backwards incompatible changes.
Date User Action Args
2017-03-03 19:20:13dhimmelsetrecipients: + dhimmel, methane, serhiy.storchaka
2017-03-03 19:20:13dhimmelsetmessageid: <>
2017-03-03 19:20:13dhimmellinkissue29636 messages
2017-03-03 19:20:13dhimmelcreate