Skip to content

bpo-29636: json.tool: Add document for indentation options. #17482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 7, 2019

Conversation

dhimmel
Copy link
Contributor

@dhimmel dhimmel commented Dec 6, 2019

#345 added indentation options for the json.tool command line utility. This PR follows up with some additional modifications that I didn't have time to put in the previous PR before it was merged.

https://bugs.python.org/issue29636

CC @methane

Mutually exclusive options for whitespace control

.. versionadded:: 3.9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wimglenn does this documentation look okay? I combined multiple arguments into a single line (not sure if that violates convention or is okay)

Lib/json/tool.py Outdated
@@ -31,7 +31,8 @@ def main():
parser.add_argument('--sort-keys', action='store_true', default=False,
help='sort the output of dictionaries alphabetically by key')
parser.add_argument('--json-lines', action='store_true', default=False,
help='parse input using the jsonlines format')
help='parse input using the jsonlines format. '
'Use with --no-indent or --compact to produce valid jsonlines output.')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hongweipeng (author of #10051): do you think this is a worthwhile and accurate addition to the documentation now that indentation options are supported?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

As per http://jsonlines.org/:

> JSON Lines is a convenient format for storing structured data
trailing newlines were previously ignored due to .splitlines
Probably is better to test for this to ensure any future
change in behavior is intentional.
@methane methane changed the title bpo-29636: touch ups to json.tool indentation options bpo-29636: json.tool: Add document for indentation options. Dec 6, 2019
@methane methane merged commit 15fb7fa into python:master Dec 7, 2019
@dhimmel
Copy link
Contributor Author

dhimmel commented Dec 12, 2019

Rendered documentation available at https://docs.python.org/3.9/library/json.html#cmdoption-json-tool-indent

image

I forgot a period after "whitespace control" ):

shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants