Skip to content

Commit 8c9d81b

Browse files
Rov-Waffpicnixz
andauthored
gh-137533:just restate the key of json must be string
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent 9b6732b commit 8c9d81b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Doc/library/json.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,10 @@ Basic Usage
366366

367367
.. note::
368368

369-
As mandated by :rfc:`8259`, keys in JSON key-value pairs are always of
370-
type :class:`str`. Therefore, dictionary keys obtained by
371-
deserializing JSON objects will always be strings.
372-
For Example,
373-
``json.loads('{"42":"spam"}')`` returns the dictionary
374-
``{'42': 'spam'}``,but ``json.loads('{42:"spam"}')``
375-
will raise a exception,because it is not a correct
376-
JSON text
369+
As mandated by :rfc:`8259`, JSON keys must be :class:`str` objects.
370+
In particular, ``json.loads('{"42": "spam"}')`` returns ``{'42': 'spam'}``,
371+
but ``json.loads('{42: "spam"}')`` fails since ``42`` is not a valid JSON key.
372+
377373

378374
Encoders and Decoders
379375
---------------------

0 commit comments

Comments
 (0)