summaryrefslogtreecommitdiffstats
path: root/Doc/library/json.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-03 21:18:54 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-03 21:18:54 (GMT)
commit48310cd3f2e02ced9ae836ccbcb67e9af3097d62 (patch)
tree04c86b387c11bfd4835a320e76bbb2ee24626e0d /Doc/library/json.rst
parent3d3558a4653fcfcbdcbb75bda5d61e93c48f4d51 (diff)
downloadcpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.zip
cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.gz
cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.bz2
Remove trailing whitespace.
Diffstat (limited to 'Doc/library/json.rst')
-rw-r--r--Doc/library/json.rst18
1 files changed, 9 insertions, 9 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index cad841e..69d4c10 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -13,7 +13,7 @@ syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.
:mod:`marshal` and :mod:`pickle` modules.
Encoding basic Python object hierarchies::
-
+
>>> import json
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
'["foo", {"bar": ["baz", null, 1.0, 2]}]'
@@ -42,12 +42,12 @@ Pretty printing::
>>> import json
>>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
{
- "4": 5,
+ "4": 5,
"6": 7
}
Decoding JSON::
-
+
>>> import json
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
['foo', {'bar': ['baz', None, 1.0, 2]}]
@@ -74,7 +74,7 @@ Specializing JSON object decoding::
Decimal('1.1')
Extending :class:`JSONEncoder`::
-
+
>>> import json
>>> class ComplexEncoder(json.JSONEncoder):
... def default(self, obj):
@@ -88,12 +88,12 @@ Extending :class:`JSONEncoder`::
'[2.0, 1.0]'
>>> list(ComplexEncoder().iterencode(2 + 1j))
['[', '2.0', ', ', '1.0', ']']
-
+
.. highlight:: none
Using json.tool from the shell to validate and pretty-print::
-
+
$ echo '{"json":"obj"}' | python -mjson.tool
{
"json": "obj"
@@ -103,7 +103,7 @@ Using json.tool from the shell to validate and pretty-print::
.. highlight:: python
-.. note::
+.. note::
The JSON produced by this module's default settings is a subset of
YAML, so it may be used as a serializer for that as well.
@@ -367,7 +367,7 @@ Encoders and decoders
For example, to support arbitrary iterators, you could implement default
like this::
-
+
def default(self, o):
try:
iterable = iter(o)
@@ -391,6 +391,6 @@ Encoders and decoders
Encode the given object, *o*, and yield each string representation as
available. For example::
-
+
for chunk in JSONEncoder().iterencode(bigobject):
mysocket.write(chunk)