Skip to content

Commit 40c5678

Browse files
committed
gh-137533:restate that keys in JSON must be strings at module-level docs
1 parent 8c9d81b commit 40c5678

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/library/json.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ is a lightweight data interchange format inspired by
2222
The term "object" in the context of JSON processing in Python can be
2323
ambiguous. All values in Python are objects. In JSON, an object refers to
2424
any data wrapped in curly braces, similar to a Python dictionary.
25-
2625
.. warning::
2726
Be cautious when parsing JSON data from untrusted sources. A malicious
2827
JSON string may cause the decoder to consume considerable CPU and memory
@@ -146,6 +145,13 @@ See :ref:`json-commandline` for detailed documentation.
146145
This module's encoders and decoders preserve input and output order by
147146
default. Order is only lost if the underlying containers are unordered.
148147

148+
.. note::
149+
According to RFC 7159, the keys of all objects in JSON are strings.
150+
Under normal circumstances,the encoder of this module
151+
will convert the keys of all Python dictionaries into strings as the
152+
keys of JSON objects, and the decoder of this module will
153+
decode the keys of all JSON objects into strings as the keys
154+
of Python dictionaries
149155

150156
Basic Usage
151157
-----------

0 commit comments

Comments
 (0)