mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
gh-122873: Allow "python -m json" to work (#122884)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
This commit is contained in:
parent
db6f5e1933
commit
906b796af8
8 changed files with 77 additions and 45 deletions
|
@ -1,14 +1,7 @@
|
|||
r"""Command-line tool to validate and pretty-print JSON
|
||||
|
||||
Usage::
|
||||
|
||||
$ echo '{"json":"obj"}' | python -m json.tool
|
||||
{
|
||||
"json": "obj"
|
||||
}
|
||||
$ echo '{ 1.2:3.4}' | python -m json.tool
|
||||
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
|
||||
"""Command-line tool to validate and pretty-print JSON
|
||||
|
||||
See `json.__main__` for a usage example (invocation as
|
||||
`python -m json.tool` is supported for backwards compatibility).
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
|
@ -16,7 +9,7 @@ import sys
|
|||
|
||||
|
||||
def main():
|
||||
prog = 'python -m json.tool'
|
||||
prog = 'python -m json'
|
||||
description = ('A simple command line interface for json module '
|
||||
'to validate and pretty-print JSON objects.')
|
||||
parser = argparse.ArgumentParser(prog=prog, description=description)
|
||||
|
@ -86,4 +79,4 @@ if __name__ == '__main__':
|
|||
try:
|
||||
main()
|
||||
except BrokenPipeError as exc:
|
||||
sys.exit(exc.errno)
|
||||
raise SystemExit(exc.errno)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue