From: Georg Brandl Date: Sat, 20 Sep 2014 22:38:13 +0000 (+0200) Subject: merge with 3.4 X-Git-Tag: v3.5.0a1~888 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e7fbde67f55e8e5c21bc41568c7fe13e72b44bc;p=python merge with 3.4 --- 9e7fbde67f55e8e5c21bc41568c7fe13e72b44bc diff --cc Doc/library/json.rst index d6bdd8a4f8,5d97ee88fc..55127c0a1f --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@@ -565,54 -563,3 +565,54 @@@ the last name-value pair for a given na {'x': 3} The *object_pairs_hook* parameter can be used to alter this behavior. + +.. highlight:: bash + +.. _json-commandline: + +Command Line Interface +---------------------- + +The :mod:`json.tool` module provides a simple command line interface to validate +and pretty-print JSON objects. + - If the optional :option:`infile` and :option:`outfile` arguments are not ++If the optional ``infile`` and ``outfile`` arguments are not +specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively:: + + $ 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 2 (char 1) + + +Command line options +^^^^^^^^^^^^^^^^^^^^ + +.. cmdoption:: infile + + The JSON file to be validated or pretty-printed:: + + $ python -m json.tool mp_films.json + [ + { + "title": "And Now for Something Completely Different", + "year": 1971 + }, + { + "title": "Monty Python and the Holy Grail", + "year": 1975 + } + ] + + If *infile* is not specified, read from :attr:`sys.stdin`. + +.. cmdoption:: outfile + + Write the output of the *infile* to the given *outfile*. Otherwise, write it + to :attr:`sys.stdout`. + +.. cmdoption:: -h, --help + + Show the help message.