From 403886c28ddb350bbcaea478f8d754ed14e10337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Srinivas=20Reddy=20Thatiparthy=20=28=E0=B0=A4=E0=B0=BE?= =?UTF-8?q?=E0=B0=9F=E0=B0=BF=E0=B0=AA=E0=B0=B0=E0=B1=8D=E0=B0=A4=E0=B0=BF?= =?UTF-8?q?=20=E0=B0=B6=E0=B1=8D=E0=B0=B0=E0=B1=80=E0=B0=A8=E0=B0=BF?= =?UTF-8?q?=E0=B0=B5=E0=B0=BE=E0=B0=B8=E0=B1=8D=20=20=E0=B0=B0=E0=B1=86?= =?UTF-8?q?=E0=B0=A1=E0=B1=8D=E0=B0=A1=E0=B0=BF=29?= Date: Tue, 8 Apr 2025 13:55:46 +0530 Subject: gh-132021: Add bool type to the list of allowed JSON key types (#132048) Co-authored-by: Eric V. Smith --- Doc/library/json.rst | 4 ++-- Lib/json/encoder.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 4e7046d..26579ec 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -486,8 +486,8 @@ Encoders and Decoders (to raise :exc:`TypeError`). If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when - trying to encode keys that are not :class:`str`, :class:`int`, :class:`float` - or ``None``. If *skipkeys* is true, such items are simply skipped. + trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`, + :class:`bool` or ``None``. If *skipkeys* is true, such items are simply skipped. If *ensure_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure_ascii* is diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index b804224..0166385 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -108,8 +108,8 @@ class JSONEncoder(object): """Constructor for JSONEncoder, with sensible defaults. If skipkeys is false, then it is a TypeError to attempt - encoding of keys that are not str, int, float or None. If - skipkeys is True, such items are simply skipped. + encoding of keys that are not str, int, float, bool or None. + If skipkeys is True, such items are simply skipped. If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If -- cgit v0.12