bpo-30550: Clarify JSON ordering guarantees (GH-15397)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Thu, 22 Aug 2019 22:14:42 +0000 (15:14 -0700)
committerGitHub <noreply@github.com>
Thu, 22 Aug 2019 22:14:42 +0000 (15:14 -0700)
Doc/library/json.rst

index b476c372370d067f8bc412d4cfd4dc847b3e7a0f..56c16f5d296a3b0cd38a6db084461268359312f4 100644 (file)
@@ -120,6 +120,18 @@ See :ref:`json-commandline` for detailed documentation.
    value) is also a subset of YAML 1.0 and 1.1.  This module can thus also be
    used as a YAML serializer.
 
+.. note::
+
+   This module's encoders and decoders preserve input and output order by
+   default.  Order is only lost if the underlying containers are unordered.
+
+   Prior to Python 3.7, :class:`dict` was not guaranteed to be ordered, so
+   inputs and outputs were typically scrambled unless
+   :class:`collections.OrderedDict` was specifically requested.  Starting
+   with Python 3.7, the regular :class:`dict` became order preserving, so
+   it is no longer necessary specify :class:`collections.OrderedDict` for
+   JSON generation and parsing.
+
 
 Basic Usage
 -----------