Announcing jsonlib2 1.5 - the simplejson release

alecf alecf at
Fri Jun 5 02:27:18 CEST 2009

I've just revved jsonlib2, the C-based json parser used at metaweb for Compared with simplejson, my initial tests have it
between 21 and 25 times faster for loads() and around 10x faster for

For those of you who have never used jsonlib/jsonlib2, all you have to
know is that with this version, jsonlib2 is much more compatible with
simplejson/json. Got a ways to go but for most applications it should
be a drop-in replacement.

This is the first C Python extension I've ever written, and I actually
inherited most of the code when I forked jsonlib because of
differences with the author. This means I'm very interested in patches/

For those using jsonlib or jsonlib2:

Version 1.5 is a big API change - loads() and dumps() are now almost
completely compatible with simplejson's loads() and dumps() - so it
really should be a drop-in replacement. Here are a few things that
have been possible with simplejson, but not with jsonlib2:

1) looser enforcement of json spec - allowing stuff like:
>>> jsonlib2.dumps({None: "foo"})
'{"null": "foo"}'

>>> jsonlib2.dumps(None)

2) full support for Infinity, NaN, in both dumping AND parsing, by
>>> jsonlib2.dumps(1e10000)
>>> jsonlib2.loads(jsonlib2.dumps(1e10000))

I've actually imported the simplejson unit tests, and this library
passes 26 of 32 tests, and most failures are just due to the fact that
jsonlib2 prefers to output in utf8 rather than unicode, for faster
output from a web server.


More information about the Python-announce-list mailing list