Message219891
| Author |
r.david.murray |
| Recipients |
Pavel.Kazlou, berker.peksag, ezio.melotti, pitrou, r.david.murray, rhettinger |
| Date |
2014年06月06日.16:44:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1402073059.92.0.726915742337.issue21650@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Yes but the input is turned into a dict, and dicts do not preserve order. Further, what is passed to the object_hook is already a dict, so the order is already lost before object_hook is called.
Since the parser (or at least the Python version of the parser) first turns the input into a list of pairs, and a Python OrderedDict can be instantiated from a list of pairs, it would theoretically be possible to extend the object_hook API to allow an OrderedDict to be used on decode. Exactly how to do that so as to retain backward compatibility is a bit of a question.
So, it is *possible* to achieve your aim, but it isn't as simple as allowing sort= to be set False.
IMO being able to preserve the order of the input when desired (ie: use an OrderedDict object_hook) would be a nice feature to have. |
|