Skip to content

Commit ffc3250

Browse files
rhettingerlisroach
authored andcommitted
bpo-30550: Clarify JSON ordering guarantees (pythonGH-15397)
1 parent 5966fd6 commit ffc3250

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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)