[issue32816] Python's json dumps/loads make integer keys of the dict str

Korabelnikov Aleksandr report at bugs.python.org
Sat Feb 10 10:59:52 EST 2018


New submission from Korabelnikov Aleksandr <nesoriti at yandex.ru>:

when i serialize and deserialize python built-in structure I'm expect output same as input

arr2 = [1,2,'3']
arr2_json = json.dumps(arr2)
json.loads(arr2_json)
Out[16]: [1, 2, '3']

BUT when I'm tring do it with dict I got str keys instead of integer

dict1 = {0: 'object0', '1': 'object2'}
json1 = json.dumps(dict1)
json.loads(json1)
Out[6]: {'0': 'object0', '1': 'object2'}

Notice keys must be [0, '1'] but actually are ['0', '1']

----------
components: Library (Lib)
messages: 311951
nosy: solin
priority: normal
severity: normal
status: open
title: Python's json dumps/loads make integer keys of the dict str
type: behavior
versions: Python 3.5

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


More information about the Python-bugs-list mailing list