[Python-checkins] r84481 - python/branches/py3k/Doc/library/json.rst

georg.brandl python-checkins at python.org
Sat Sep 4 00:36:23 CEST 2010


Author: georg.brandl
Date: Sat Sep  4 00:36:22 2010
New Revision: 84481

Log:
#9767: doctest run over json docs.

Modified:
   python/branches/py3k/Doc/library/json.rst

Modified: python/branches/py3k/Doc/library/json.rst
==============================================================================
--- python/branches/py3k/Doc/library/json.rst	(original)
+++ python/branches/py3k/Doc/library/json.rst	Sat Sep  4 00:36:22 2010
@@ -82,12 +82,12 @@
     ...             return [obj.real, obj.imag]
     ...         return json.JSONEncoder.default(self, obj)
     ...
-    >>> dumps(2 + 1j, cls=ComplexEncoder)
+    >>> json.dumps(2 + 1j, cls=ComplexEncoder)
     '[2.0, 1.0]'
     >>> ComplexEncoder().encode(2 + 1j)
     '[2.0, 1.0]'
     >>> list(ComplexEncoder().iterencode(2 + 1j))
-    ['[', '2.0', ', ', '1.0', ']']
+    ['[2.0', ', 1.0', ']']
 
 
 .. highlight:: none
@@ -373,7 +373,7 @@
                 pass
             else:
                 return list(iterable)
-            return JSONEncoder.default(self, o)
+            return json.JSONEncoder.default(self, o)
 
 
    .. method:: encode(o)
@@ -381,7 +381,7 @@
       Return a JSON string representation of a Python data structure, *o*.  For
       example::
 
-        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
+        >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]})
         '{"foo": ["bar", "baz"]}'
 
 
@@ -390,5 +390,5 @@
       Encode the given object, *o*, and yield each string representation as
       available.  For example::
 
-            for chunk in JSONEncoder().iterencode(bigobject):
+            for chunk in json.JSONEncoder().iterencode(bigobject):
                 mysocket.write(chunk)


More information about the Python-checkins mailing list