summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2011-09-03 19:16:07 -0700
committerBob Ippolito <bob@redivi.com>2011-09-03 19:16:07 -0700
commit50631cf809830d4c398cee58159643913cd89411 (patch)
tree859ddcd4731555c2acbf697a111cac7de5ff924e
parent308b7421566889b10766cdab144874e29b38ff99 (diff)
downloadsimplejson-50631cf809830d4c398cee58159643913cd89411.tar.gz
update docs with namedtuple encoding to JSON object
-rw-r--r--CHANGES.txt5
-rw-r--r--index.rst5
-rw-r--r--simplejson/encoder.py2
3 files changed, 9 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 4861628..429a9ab 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,8 @@
-Version 2.1.7 released 2011-XX-XX
+Version 2.2.0 released 2011-XX-XX
+* namedtuple (or other tuple subclasses with _asdict methods) are now
+ encoded as JSON objects rather than arrays.
+ https://github.com/simplejson/simplejson/pull/6
* JSONDecodeError is now raised instead of ValueError when a document
ends with an opening quote and the C speedups are in use.
https://github.com/simplejson/simplejson/issues/15
diff --git a/index.rst b/index.rst
index b478e5c..2d49ef9 100644
--- a/index.rst
+++ b/index.rst
@@ -399,7 +399,7 @@ Encoders and decoders
+-------------------+---------------+
| Python | JSON |
+===================+===============+
- | dict | object |
+ | dict, namedtuple | object |
+-------------------+---------------+
| list, tuple | array |
+-------------------+---------------+
@@ -414,6 +414,9 @@ Encoders and decoders
| None | null |
+-------------------+---------------+
+ .. versionchanged:: 2.2.0
+ Changed *namedtuple* encoding from JSON array to object.
+
To extend this to recognize other objects, subclass and implement a
:meth:`default` method with another method that returns a serializable object
for ``o`` if possible, otherwise it should call the superclass implementation
diff --git a/simplejson/encoder.py b/simplejson/encoder.py
index c72bd7f..9909eb5 100644
--- a/simplejson/encoder.py
+++ b/simplejson/encoder.py
@@ -80,7 +80,7 @@ class JSONEncoder(object):
+-------------------+---------------+
| Python | JSON |
+===================+===============+
- | dict | object |
+ | dict, namedtuple | object |
+-------------------+---------------+
| list, tuple | array |
+-------------------+---------------+