]> granicus.if.org Git - python/commitdiff
3.2 explain json.dumps for non-string keys in dicts. closes issue6566. Patch contribu...
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 17 Mar 2012 07:40:34 +0000 (00:40 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 17 Mar 2012 07:40:34 +0000 (00:40 -0700)
Doc/library/json.rst

index a791259831788681390a446995c11a85b43b1968..f65670088776384335b9b777ad08ee0fe4b75e9a 100644 (file)
@@ -168,6 +168,14 @@ Basic Usage
       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)