[issue26724] Serialize dict with non-string keys to JSON — unexpected result
anton-ryzhov
report at bugs.python.org
Sat Apr 9 16:03:30 EDT 2016
New submission from anton-ryzhov:
JSON doesn't allow to have non-sting keys in objects, so json.dumps converts its to string. But if several keys has one string representation — we'll get damaged result as follows:
>>> import json
>>> json.dumps({1: 2, "1": "2"})
'{"1": 2, "1": "2"}'
I think it should raise ValueError in this case.
I've tested this case on 2.7, 3.4 and on trunk version 3.6.
----------
components: Library (Lib)
messages: 263108
nosy: anton-ryzhov
priority: normal
severity: normal
status: open
title: Serialize dict with non-string keys to JSON — unexpected result
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26724>
_______________________________________
More information about the Python-bugs-list
mailing list