I have a json object which is a list of dicts (each describing an event with a dict containing the parameters of the event). bson.dumps(jsonListOfDicts) raises an attribute Error:
In [1]: import bson
In [2]: bson.dumps([{"a": [1, 2, 3]}, {"a": [2, 3, 4]}])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-ed4dc1257349> in <module>()
----> 1 bson.dumps([{"a": [1, 2, 3]}, {"a": [2, 3, 4]}])
/home/fabian/mount/data/LinuxDaten/software/anaconda/lib/python2.7/site-packages/bson/__init__.pyc in dumps(obj, generator)
36 if isinstance(obj, BSONCoding):
37 return encode_object(obj, [], generator_func=generator)
---> 38 return encode_document(obj, [], generator_func=generator)
39
40
/home/fabian/mount/data/LinuxDaten/software/anaconda/lib/python2.7/site-packages/bson/codec.pyc in encode_document(obj, traversal_stack, traversal_parent, generator_func)
223 def encode_document(obj, traversal_stack, traversal_parent=None, generator_func=None):
224 buf = StringIO()
--> 225 key_iter = iterkeys(obj)
226 if generator_func is not None:
227 key_iter = generator_func(obj, traversal_stack)
/home/fabian/mount/data/LinuxDaten/software/anaconda/lib/python2.7/site-packages/six.pyc in iterkeys(d, **kw)
568 else:
569 def iterkeys(d, **kw):
--> 570 return iter(d.iterkeys(**kw))
571
572 def itervalues(d, **kw):
AttributeError: 'list' object has no attribute 'iterkeys'
Would be nice if bson also could support such json objects.