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

index 546a09d69bde611adcf1a74e12ebb9ce6fc4f6ef..6d4497f2241f025c5d112ba691deb59ce292e89c 100644 (file)
@@ -170,6 +170,14 @@ Basic Usage
    :class:`unicode` instance.  The other arguments have the same meaning as in
    :func:`dump`.
 
+   .. 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[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]])