Author dhimmel
Recipients dhimmel, inada.naoki, serhiy.storchaka
Date 2017-03-03.19:20:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488568813.97.0.565121589745.issue29636@psf.upfronthosting.co.za>
In-reply-to
Content
To recap the discussion from https://git.io/vyCY8: there are three potential mutually exclusive command line options that have been suggested. There are as follows.

```python
import json
obj = [1, 2]

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

print('--no-indent')
print(json.dumps(obj, indent=None))

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

which produces the following output:


```
--indent=4
[
    1,
    2
]
--no-indent
[1, 2]
--compact
[1,2]
```

Currently, https://github.com/python/cpython/pull/345 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 http://bugs.python.org/issue29540). 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.
History
Date User Action Args
2017-03-03 19:20:13dhimmelsetrecipients: + dhimmel, inada.naoki, serhiy.storchaka
2017-03-03 19:20:13dhimmelsetmessageid: <1488568813.97.0.565121589745.issue29636@psf.upfronthosting.co.za>
2017-03-03 19:20:13dhimmellinkissue29636 messages
2017-03-03 19:20:13dhimmelcreate