Skip to content

Commit 2fa19d2

Browse files
srinivasreddyericvsmith
authored andcommitted
pythongh-132021: Add bool type to the list of allowed JSON key types (pythonGH-132048)
(cherry picked from commit 403886c) Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <[email protected]> Co-authored-by: Eric V. Smith <[email protected]>
1 parent 53b9370 commit 2fa19d2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Doc/library/json.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ Encoders and Decoders
486486
(to raise :exc:`TypeError`).
487487

488488
If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when
489-
trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`
490-
or ``None``. If *skipkeys* is true, such items are simply skipped.
489+
trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`,
490+
:class:`bool` or ``None``. If *skipkeys* is true, such items are simply skipped.
491491

492492
If *ensure_ascii* is true (the default), the output is guaranteed to
493493
have all incoming non-ASCII characters escaped. If *ensure_ascii* is

Lib/json/encoder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def __init__(self, *, skipkeys=False, ensure_ascii=True,
108108
"""Constructor for JSONEncoder, with sensible defaults.
109109
110110
If skipkeys is false, then it is a TypeError to attempt
111-
encoding of keys that are not str, int, float or None. If
112-
skipkeys is True, such items are simply skipped.
111+
encoding of keys that are not str, int, float, bool or None.
112+
If skipkeys is True, such items are simply skipped.
113113
114114
If ensure_ascii is true, the output is guaranteed to be str
115115
objects with all incoming non-ASCII characters escaped. If

0 commit comments

Comments
 (0)