-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Conversation
Mutually exclusive options for whitespace control | ||
|
||
.. versionadded:: 3.9 | ||
|
There was a problem hiding this comment.
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.') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Rendered documentation available at https://docs.python.org/3.9/library/json.html#cmdoption-json-tool-indent I forgot a period after "whitespace control" ): |
…-17482) And updated test to use subprocess.run
#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