[Python-Dev] cpython (3.2): 3.2 explain json.dumps for non-string keys in dicts. closes issue6566. Patch
Georg Brandl
g.brandl at gmx.net
Sat Mar 17 17:46:42 CET 2012
On 03/17/2012 08:41 AM, senthil.kumaran wrote:
> http://hg.python.org/cpython/rev/613919591a05
> changeset: 75778:613919591a05
> branch: 3.2
> parent: 75771:32d3ecacdabf
> user: Senthil Kumaran <senthil at uthcode.com>
> date: Sat Mar 17 00:40:34 2012 -0700
> summary:
> 3.2 explain json.dumps for non-string keys in dicts. closes issue6566. Patch contributed Kirubakaran Athmanathan
>
> files:
> Doc/library/json.rst | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
>
> diff --git a/Doc/library/json.rst b/Doc/library/json.rst
> --- a/Doc/library/json.rst
> +++ b/Doc/library/json.rst
> @@ -168,6 +168,14 @@
> so trying to serialize multiple objects with repeated calls to
> :func:`dump` using the same *fp* will result in an invalid JSON file.
>
> + .. note::
> +
> + Keys in key/value pairs of JSON are always of the type :class:`str`. When
> + a dictionary is converted into JSON, all the keys of the dictionary are
> + coerced to strings. As a result of this, if a dictionary is convered
> + into JSON and then back into a dictionary, the dictionary may not equal
> + the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
> + keys.
>
> .. function:: load(fp, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
This is just a minor nitpick, and it absolutely is not specific to you, Senthil:
please try to keep the rst file structuring with newlines intact. In
particular, I place two blank lines between top-level function/class
descriptions because single blank lines already occur so often in rst markup.
When you add paragraphs, please try to keep the blank lines.
Georg
More information about the Python-Dev
mailing list