summaryrefslogtreecommitdiffstats
path: root/Doc/library/json.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-09-03 22:36:22 (GMT)
committerGeorg Brandl <georg@python.org>2010-09-03 22:36:22 (GMT)
commit0bb73b8be8b4bf6b198ec86124424b3078c6c9c0 (patch)
tree113be5a605e173c39049d4de92b0da544fe9eeee /Doc/library/json.rst
parent8d582160506aa57f182fc27b055e16b2ff140968 (diff)
downloadcpython-0bb73b8be8b4bf6b198ec86124424b3078c6c9c0.zip
cpython-0bb73b8be8b4bf6b198ec86124424b3078c6c9c0.tar.gz
cpython-0bb73b8be8b4bf6b198ec86124424b3078c6c9c0.tar.bz2
#9767: doctest run over json docs.
Diffstat (limited to 'Doc/library/json.rst')
-rw-r--r--Doc/library/json.rst10
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index ac097f7..3b203a2 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -82,12 +82,12 @@ Extending :class:`JSONEncoder`::
... 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 @@ Encoders and decoders
pass
else:
return list(iterable)
- return JSONEncoder.default(self, o)
+ return json.JSONEncoder.default(self, o)
.. method:: encode(o)
@@ -381,7 +381,7 @@ Encoders and decoders
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 @@ Encoders and decoders
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)