anyjson /

Filename Size Date modified Message
49 B
Added ignore file
840 B
Added tag 0.3.3 for changeset 5d726a88af5b
1.6 KB
Bumped version, updated changelog
1.5 KB
Split up readme into separate parts.
60 B
Make sure tests are included when running python sdist. Resolves #8
1.6 KB
renamed README
2.9 KB
Now depends on simlejson if no other json libs installed
76 B
Added tox config

anyjson - JSON library wrapper


Anyjson loads whichever is the fastest JSON module installed and provides a uniform API regardless of which JSON implementation is used.

Originally part of carrot (


To serialize a python object to a JSON string, call the serialize function:

>>> import anyjson
>>> anyjson.serialize(["test", 1, {"foo": 3.141592}, "bar"])
'["test", 1, {"foo": 3.141592}, "bar"]'

Conversion the other way is done with the deserialize call.

>>> anyjson.deserialize("""["test", 1, {"foo": 3.141592}, "bar"]""")
['test', 1, {'foo': 3.1415920000000002}, 'bar']

Regardless of the JSON implementation used, the exceptions will be the same. This means that trying to serialize something not compatible with JSON raises a TypeError:

>>> anyjson.serialize([object()])
Traceback (most recent call last):
  <snipped traceback>
TypeError: object is not JSON encodable

And deserializing a JSON string with invalid JSON raises a ValueError:

>>> anyjson.deserialize("""['missing square brace!""")
Traceback (most recent call last):
  <snipped traceback>
ValueError: cannot parse JSON description


The module is maintaned by Rune F. Halvorsen <>. The project resides at . Bugs and feature requests can be submitted there. Patches are also very welcome.




see the LICENSE file