Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 657008e

Browse files
authored
bpo-30550: Clarify JSON ordering guarantees (GH-15397)
1 parent 4be11c0 commit 657008e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/library/json.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ See :ref:`json-commandline` for detailed documentation.
120120
value) is also a subset of YAML 1.0 and 1.1. This module can thus also be
121121
used as a YAML serializer.
122122

123+
.. note::
124+
125+
This module's encoders and decoders preserve input and output order by
126+
default. Order is only lost if the underlying containers are unordered.
127+
128+
Prior to Python 3.7, :class:`dict` was not guaranteed to be ordered, so
129+
inputs and outputs were typically scrambled unless
130+
:class:`collections.OrderedDict` was specifically requested. Starting
131+
with Python 3.7, the regular :class:`dict` became order preserving, so
132+
it is no longer necessary specify :class:`collections.OrderedDict` for
133+
JSON generation and parsing.
134+
123135

124136
Basic Usage
125137
-----------

0 commit comments

Comments
 (0)