Some values are serialized differently between simplejson and json.
Notably, instances of collections.namedtuple
are serialized as arrays by json
but as objects by simplejson
. You can override this behaviour by passing namedtuple_as_object=False
to simplejson.dump
, but by default the behaviours do not match.
>>> import collections, simplejson, json
>>> TupleClass = collections.namedtuple("TupleClass", ("a", "b"))
>>> value = TupleClass(1, 2)
>>> json.dumps(value)
'[1, 2]'
>>> simplejson.dumps(value)
'{"a": 1, "b": 2}'
>>> simplejson.dumps(value, namedtuple_as_object=False)
'[1, 2]'