[issue38414] Ordering a nested dictionary in python with json format

Serhiy Storchaka report at bugs.python.org
Wed Oct 9 02:18:06 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Dictionary preserve the insertion order starting from Python 3.7 (actually from 3.6, but it was not guarantied). I am surprised that you got different result in 3.6. I cannot reproduce it.

In older Python versions you can pass object_pairs_hook=OrderedDict to json.loads() to preserve the insertion order. The regular dictionary cannot preserve it, by its structure.

----------
nosy: +serhiy.storchaka
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38414>
_______________________________________


More information about the Python-bugs-list mailing list