summaryrefslogtreecommitdiff
path: root/index.rst
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2011-09-04 16:54:47 -0700
committerBob Ippolito <bob@redivi.com>2011-09-04 16:54:47 -0700
commit49724ee06f038d27ab3d4adbe4ed403692799aa1 (patch)
tree042bdb95043f9172a5d8fc78a61c89e57275a844 /index.rst
parentba669afbfcc2306033bb38b900f9a22d217cb233 (diff)
downloadsimplejson-49724ee06f038d27ab3d4adbe4ed403692799aa1.tar.gz
2.3.0 and iterable_as_array encoding optioniterable_as_array-gh1
Diffstat (limited to 'index.rst')
-rw-r--r--index.rst31
1 files changed, 27 insertions, 4 deletions
diff --git a/index.rst b/index.rst
index 11f076e..b965982 100644
--- a/index.rst
+++ b/index.rst
@@ -129,7 +129,7 @@ Using :mod:`simplejson.tool` from the shell to validate and pretty-print::
Basic Usage
-----------
-.. function:: dump(obj, fp[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, **kw]]]]]]]]]]]]])
+.. function:: dump(obj, fp[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, iterable_as_array[, **kw]]]]]]]]]]]]]])
Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-supporting
file-like object).
@@ -192,7 +192,7 @@ Basic Usage
If *namedtuple_as_object* is true (default: ``True``),
:class:`tuple` subclasses with ``_asdict()`` methods will be encoded
as JSON objects.
-
+
.. versionchanged:: 2.2.0
*namedtuple_as_object* is new in 2.2.0.
@@ -202,6 +202,14 @@ Basic Usage
.. versionchanged:: 2.2.0
*tuple_as_array* is new in 2.2.0.
+ If *iterable_as_array* is true (default: ``False``),
+ any object not in the above table that implements ``__iter__()``
+ will be encoded as a JSON array.
+
+ .. versionchanged:: 2.3.0
+ *iterable_as_array* is new in 2.3.0.
+
+
.. note::
JSON is not a framed protocol so unlike :mod:`pickle` or :mod:`marshal` it
@@ -209,7 +217,7 @@ Basic Usage
container protocol to delimit them.
-.. function:: dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, **kw]]]]]]]]]]]]])
+.. function:: dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, iterable_as_array[, **kw]]]]]]]]]]]]]])
Serialize *obj* to a JSON formatted :class:`str`.
@@ -274,6 +282,14 @@ Basic Usage
.. versionchanged:: 2.1.0
*use_decimal* is new in 2.1.0.
+ If *iterable_as_array* is true (default: ``False``),
+ any object not in the above table that implements ``__iter__()``
+ will be encoded as a JSON array.
+
+ .. versionchanged:: 2.3.0
+ *iterable_as_array* is new in 2.3.0.
+
+
To use a custom :class:`JSONDecoder` subclass, specify it with the ``cls``
kwarg. Additional keyword arguments will be passed to the constructor of the
class.
@@ -406,7 +422,7 @@ Encoders and decoders
:exc:`JSONDecodeError` will be raised if the given JSON
document is not valid.
-.. class:: JSONEncoder([skipkeys[, ensure_ascii[, check_circular[, allow_nan[, sort_keys[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array]]]]]]]]]]]])
+.. class:: JSONEncoder([skipkeys[, ensure_ascii[, check_circular[, allow_nan[, sort_keys[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, iterable_as_array]]]]]]]]]]]]])
Extensible JSON encoder for Python data structures.
@@ -496,6 +512,13 @@ Encoders and decoders
.. versionchanged:: 2.2.0
*tuple_as_array* is new in 2.2.0.
+ If *iterable_as_array* is true (default: ``False``),
+ any object not in the above table that implements ``__iter__()``
+ will be encoded as a JSON array.
+
+ .. versionchanged:: 2.3.0
+ *iterable_as_array* is new in 2.3.0.
+
.. method:: default(o)
Implement this method in a subclass such that it returns a serializable