]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-132021: Add bool type to the list of allowed JSON key types (#132048)
authorSrinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <thatiparthysreenivas@gmail.com>
Tue, 8 Apr 2025 08:25:46 +0000 (13:55 +0530)
committerGitHub <noreply@github.com>
Tue, 8 Apr 2025 08:25:46 +0000 (11:25 +0300)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Doc/library/json.rst
Lib/json/encoder.py

index 4e7046d6d8f6ac43b4b4c71fdc2923668d53f058..26579ec6328860210c0d4c78b6771d78817d6c49 100644 (file)
@@ -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
index b804224098e14f8f2418b8e29e78035009ca93b5..016638549aa59b699664af281dcb9a8f6d172c10 100644 (file)
@@ -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