This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lebigot
Recipients lebigot
Date 2017-06-02.09:47:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496396847.32.0.655591837652.issue30550@psf.upfronthosting.co.za>
In-reply-to
Content
The JSON encoder for dictionaries preserves the order of the items in a dictionary: it would be useful to document this behavior, so that users can rely on it.

While JSON itself does not have ordered key/value pairs, this feature can be useful (for modifying the original JSON document while maintaining as much of it untouched, for manipulating our own extension of JSON with ordered dictionaries, etc.).

The documentation could also usefully mention that _reading_ sets of key/value pairs can also be done in an order-preserving way with `object_pairs_hook=OrderedDict`.

Reference: the json module does not alter the order of the dictionary items upon encoding: https://github.com/python/cpython/blob/aacd53f6cb96fe8c4fe9ce894f22e25f356a97c3/Lib/json/encoder.py#L355.
History
Date User Action Args
2017-06-02 09:47:27lebigotsetrecipients: + lebigot
2017-06-02 09:47:27lebigotsetmessageid: <1496396847.32.0.655591837652.issue30550@psf.upfronthosting.co.za>
2017-06-02 09:47:27lebigotlinkissue30550 messages
2017-06-02 09:47:26lebigotcreate