Message295001
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. |
|
Date |
User |
Action |
Args |
2017-06-02 09:47:27 | lebigot | set | recipients:
+ lebigot |
2017-06-02 09:47:27 | lebigot | set | messageid: <1496396847.32.0.655591837652.issue30550@psf.upfronthosting.co.za> |
2017-06-02 09:47:27 | lebigot | link | issue30550 messages |
2017-06-02 09:47:26 | lebigot | create | |
|