Commit Graph

125 Commits

Author SHA1 Message Date
Pieter Eendebak 05adfbba2a
gh-95382: Improve performance of json encoder with indent (GH-118105) 2024-05-06 11:04:39 +03:00
Jan Max Meyer 647053fed1
doc: Use super() in subclassed JSONEncoder examples (GH-115565)
Replace calls to `json.JSONEncoder.default(self, obj)`
by `super().default(obj)` within the examples of the documentation.
2024-02-28 14:54:12 +01:00
Serhiy Storchaka b3d2427f22
gh-58032: Do not use argparse.FileType in module CLIs and scripts (GH-113649)
Open and close files manually. It prevents from leaking files,
preliminary creation of output files, and accidental closing of stdin
and stdout.
2024-01-10 15:07:19 +02:00
Carson Radtke cfa25fe3e3
gh-113149: Improve error message when JSON has trailing comma (GH-113227) 2023-12-17 20:52:26 +02:00
Łukasz Langa d3af83b934
Revert "GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)" (#105948)
This reverts commit 1f0eafa844.
2023-06-26 20:35:53 +02:00
Serhiy Storchaka db39050396
gh-96959: Update HTTP links which are redirected to HTTPS (GH-96961) 2022-09-24 14:38:53 +03:00
Raymond Hettinger 1f0eafa844
GH-96145: Add AttrDict to JSON module for use with object_hook (#96146) 2022-08-23 16:22:00 -05:00
Nikita Sobolev 0cbdd21311
bpo-46565: `del` loop vars that are leaking into module namespaces (GH-30993) 2022-02-03 11:20:08 +02:00
James Gerity 8db06528ca
bpo-46001: Change OverflowError to RecursionError in JSON library docstrings (GH-29943) 2021-12-07 11:58:40 +02:00
Chris Wesseling 815dad42d5
bpo-45644: Make json.tool read infile before writing to outfile (GH-29273)
so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-11-06 18:11:35 +01:00
Dong-hee Na 700cb58730
bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779) 2020-03-10 08:41:44 +01:00
Inada Naoki 5492bfcefe
bpo-39377: json: Remove the encoding option. (GH-18075) 2020-01-20 13:54:00 +09:00
Daniel Himmelstein 15fb7fa881 bpo-29636: json.tool: Add document for indentation options. (GH-17482)
And updated test to use subprocess.run
2019-12-07 23:14:40 +09:00
wim glenn efefe25443 bpo-27413: json.tool: Add --no-ensure-ascii option. (GH-17472) 2019-12-06 15:44:01 +09:00
Inada Naoki 808769f3a4
bpo-33684: json.tool: Use utf-8 for infile and outfile. (GH-17460) 2019-12-04 18:39:31 +09:00
Daniel Himmelstein 03257949bc bpo-29636: Add --(no-)indent arguments to json.tool (GH-345) 2019-12-04 15:15:19 +09:00
Hervé Beraud 4d45a3b110 json.tool: use stdin and stdout in default cmdlne arguments (GH-11992)
Argparse can handle default value as stdin and stdout for parameters
as file type (infile, outfile).
2019-05-14 18:52:42 +02:00
Serhiy Storchaka 96aeaec647
bpo-36793: Remove unneeded __str__ definitions. (GH-13081)
Classes that define __str__ the same as __repr__ can
just inherit it from object.
2019-05-06 22:29:40 +03:00
Matthias Bussonnier a8abe097c1 bpo-33461: emit DeprecationWarning when json.loads(encoding=...) is used (GH-6762) 2019-04-09 16:17:25 +09:00
HongWeipeng f194479949 bpo-31553: add --json-lines option to json.tool (#10051)
* add jsonlines option to json.tool

* code review

* fix:avoid read infile after it close

* improve doc in whatsnew 3.8
2018-11-07 12:09:32 +02:00
INADA Naoki e25399b40c
bpo-23493: json: Change sort_keys in Python encoder same to C (GH-8131)
Stop using key=lambda.  This behavior is same to C version encoder.
2018-07-07 08:55:03 +09:00
Serhiy Storchaka ae00fb1d4f
bpo-30877: Fix clearing a cache in the the JSON decoder. (GH-7048) 2018-05-22 14:55:07 +03:00
INADA Naoki 629338f140
bpo-32360: Remove object_pairs_hook=OrderedDict examples (GH-5001) 2018-04-03 12:39:47 +09:00
INADA Naoki 2812d3d992
bpo-32360: Remove OrderedDict usage from json.tool (GH-5315)
`object_pairs_hook=OrderedDict` idiom is deprecated.
2018-01-25 19:52:58 +09:00
Serhiy Storchaka cfa797c068
bpo-24641: Improved error message for JSON unserializible keys. (#4364)
Also updated an example for default() in the module docstring.
Removed quotes around type name in other error messages.
2017-11-25 17:38:20 +02:00
dong-jy 76c567ee27 Fix trivial typo in json module docstring (GH-2274) 2017-06-20 13:07:20 -07:00
Serhiy Storchaka 5affd23e6f bpo-29762: More use "raise from None". (#569)
This hides unwanted implementation details from tracebacks.
2017-04-05 09:37:24 +03:00
Serhiy Storchaka 58d3e54556 Fixed the documentation of parse_constant argument in json.load().
parse_constant doesn't get called on 'null', 'true', 'false' since 3.1/2.7.
2016-11-12 22:48:33 +02:00
Serhiy Storchaka 022371ff94 Fixed the documentation of parse_constant argument in json.load().
parse_constant doesn't get called on 'null', 'true', 'false' since 3.1/2.7.
2016-11-12 22:47:16 +02:00
Serhiy Storchaka c4a35daa97 Issue #28541: Improve test coverage for encoding detection in json library.
Original patch by Eric Appelt.
2016-10-30 23:00:01 +02:00
Nick Coghlan b161562f72 Issue #17909: Accept binary input in json.loads
json.loads (and hence json.load) now support binary input
encoded as UTF-8, UTF-16 or UTF-32.

Patch by Serhiy Storchaka.
2016-09-10 20:16:18 +10:00
Serhiy Storchaka ee047e589d Issue #4945: Improved the documenting of boolean arguments in the json module.
Based on patch by Gabriel Genellina.
2016-06-30 14:03:21 +03:00
Serhiy Storchaka 15287f8bcc Issue #4945: Improved the documenting of boolean arguments in the json module.
Based on patch by Gabriel Genellina.
2016-06-30 13:59:12 +03:00
Serhiy Storchaka aacd53f6cb Issue #18726: All optional parameters of the dump(), dumps(),
load() and loads() functions and JSONEncoder and JSONDecoder class
constructors in the json module are now keyword-only.
2016-06-22 00:03:20 +03:00
Serhiy Storchaka 47c5474aa0 Issue #26623: TypeError message for JSON unserializible object now contains
object's type name, not object's representation.
Based on patch by Mahmoud Lababidi.
2016-04-10 15:46:30 +03:00
Serhiy Storchaka e0805cf10e Issue #26719: More efficient formatting of ints and floats in json. 2016-04-10 14:41:19 +03:00
Ned Deily 53ecc58bd9 Issue #24540: merger from 3.4 2015-07-05 11:45:31 -07:00
Ned Deily 54630d999f Issue #24540: fix typo in json.dumps docstring 2015-07-05 11:45:01 -07:00
Serhiy Storchaka 47efb4a5dc Issue #19361: JSON decoder now raises JSONDecodeError instead of ValueError. 2015-01-26 13:16:30 +02:00
Antoine Pitrou dc3eaa80d4 Issue #23206: Make ``json.dumps(..., ensure_ascii=False)`` as fast as the default case of ``ensure_ascii=True``. Patch by Naoki Inada. 2015-01-11 16:41:01 +01:00
Berker Peksag 39e4c4d873 Issue #21650: Add an `--sort-keys` option to json.tool CLI. 2014-11-10 09:56:54 +02:00
Benjamin Peterson 940e207412 improve the command-line interface of json.tool (closes #21000)
A patch from Berker Peksag.
2014-03-21 23:17:29 -05:00
Gregory P. Smith f491f92529 Remove mentions of Python 2.x and being externally maintained from
the bundled json module.  Replace that with a mention of it being
a version of the externally maintained simplejson module.
2013-12-08 00:39:36 -08:00
Gregory P. Smith a82f74dee3 Remove mentions of Python 2.x and being externally maintained from
the bundled json module.  Replace that with a mention of it being
a version of the externally maintained simplejson module.
2013-12-08 00:39:07 -08:00
Serhiy Storchaka 687ff0ecdf Issue #11489: JSON decoder now accepts lone surrogates. 2013-11-26 21:27:11 +02:00
Serhiy Storchaka c93329b3dd Issue #11489: JSON decoder now accepts lone surrogates. 2013-11-26 21:25:28 +02:00
Ezio Melotti 566a2be95c #18958: Improve error message for json.load(s) while passing a string that starts with a UTF-8 BOM. 2013-10-21 02:10:55 +03:00
Ezio Melotti a0e768ccc2 #19307: Improve error message for json.load(s) while passing objects of the wrong type. 2013-10-21 01:52:33 +03:00
Ethan Furman a4998a7041 Close #18264: int- and float-derived enums now converted to int or float. 2013-08-10 13:01:45 -07:00
Brett Cannon cd171c8e92 Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a) 2013-07-04 17:43:24 -04:00