homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json serializer implicitly stringifies non-string keys
Type: Stage:
Components: Documentation Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, cvrebert, docs@python, mark.dickinson, python-dev
Priority: normal Keywords:

Created on 2014年03月29日 02:02 by cvrebert, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (4)
msg215105 - (view) Author: Chris Rebert (cvrebert) * Date: 2014年03月29日 02:02
Python 3.3.4 (default, Feb 21 2014, 18:00:34) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from json import dumps
>>> dumps({True: True, False: False, None: None, 42: 42})
'{"false": false, "true": true, "42": 42, "null": null}'
>>>
This implicit stringification of non-string dictionary keys does not currently appear to be documented.
msg215129 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014年03月29日 13:34
> This implicit stringification of non-string dictionary keys does not
> currently appear to be documented.
I think this is part of the JSON spec. See http://json.org/object.gif for example.
Also, this is already documented in the json.dumps() documentation:
> Keys in key/value pairs of JSON are always of the type str. When a
> dictionary is converted into JSON, all the keys of the dictionary are
> coerced to strings.
http://docs.python.org/3.4/library/json.html#json.dumps 
msg233847 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015年01月11日 13:23
New changeset 36099a05d76a by Mark Dickinson in branch 'default':
Issue #21092: Merge from 3.4.
https://hg.python.org/cpython/rev/36099a05d76a 
msg233849 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2015年01月11日 13:28
Sorry; that last commit message should have been for #21902.
History
Date User Action Args
2022年04月11日 14:58:00adminsetgithub: 65291
2015年01月11日 13:28:15mark.dickinsonsetnosy: + mark.dickinson
messages: + msg233849
2015年01月11日 13:23:42python-devsetnosy: + python-dev
messages: + msg233847
2014年03月29日 13:39:11brett.cannonsetstatus: open -> closed
resolution: not a bug
2014年03月29日 13:34:14berker.peksagsetnosy: + berker.peksag
messages: + msg215129
2014年03月29日 02:02:12cvrebertcreate

AltStyle によって変換されたページ (->オリジナル) /