Skip to content

Commit 403886c

Browse files
gh-132021: Add bool type to the list of allowed JSON key types (#132048)
Co-authored-by: Eric V. Smith <[email protected]>
1 parent f7305a0 commit 403886c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: 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

Diff for: 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)