This report is out-of-date.
The state of things has changed dramatically, for the better, since I first wrote this in early 2008. Although my test cases are still quite useful, any information regarding specific python packages is likely to be inaccurate. I am leaving these pages here primarily for historic interest.
As of March 20, 2008
In this report I've attempted to rigorously compare many of the currently available Python language modules for manipulating JSON encoded data. My primary intent is to determine how well each module conforms to the JSON specification, as documented in RFC 4627, as well as identifying nuances in how each maps various Python language constructs to JSON constructs.
Although credit is due to JSON creator Douglas Crockford for one of the simplest language-independent data interchange formats; it can still be deceptively easy to implement correctly. I hope my rigor here helps all software authors to improve their offerings; and in the end improves data interchange and interoperability for everybody. Perhaps even those implementing JSON in other programming languages may find something useful here.
One of the modules analyzed, demjson, is my own creation. Regardless, I've tried to remain objective in my analysis. I do welcome any feedback or corrections. Please remember that software rarely stands still, so when you read this report the state of the software may have changed‒hopefully for the better.
JSON validators
There are numerous on-the-web validators of JSON, most notably the jsonlint.org. However those validators, though useful, are not exceptionally rigourous.
For use in Python, there is:
- demjson which comes with a "jsonlint" command. This one written by me is very strict.
- jsonvalidator.py is a pretty good validator too. Written by Neil Fraser.
Introducing the modules tested
2008-03-24: Newer versions of jsonlib and simplejson have recently been released, partly to address issues covered by this report. I have not yet updated this report to reflect these new version; please check back in a few days.
These are the JSON modules that I've compared for this report. It is important to note the specific version I've used, as things change.
I am only focusing on modules which provide generic JSON encoding and decoding functionality; no attempt is made to analyze expanded functionality such as JSON-RPC or modules which are too specifically tied to a larger framework to be easily used generically.
If you are looking for something else, a good place to start is to search the PyPI database for all JSON-related Python projects.
| Module | Version tested | Author/ maintainer |
License | Minimum Python version |
Notes | |
|---|---|---|---|---|---|---|
| Version | Date | |||||
| demjson | 1.3 | 2008-03-18 | Deron Meranda | GPL 3.0+ | 2.3 | Pure python |
| jsonlib | 1.2.5 | 2008-03-15 | John Millikin | MIT | 2.4 | Uses C extension |
| JsonUtils | 0.1 | 2006-09-18 | Russell Moffitt | LGPL 2.1+ | ? | Includes python-json module; adds JSON-RPC functionality. |
| python-cjson | 1.0.5 | 2007-08-24 | Dan Pascu | LGPL 2+ | ? | Uses C extension |
| python-json | 3.4 | 2005-08-09 | Patrick Dlogan | LGPL 2.1+ | 2.4 ? | Pure python |
| simplejson | 1.7.5 | 2008-03-16 | Bob Ippolito | MIT | 2.3 | Optional C speed-up extension |
demjson
import demjson # Converting Python to JSON json_object = demjson.encode( python_object ) # Converting JSON to Python python_object = demjson.decode( json_object )
jsonlib
import jsonlib # Converting Python to JSON json_object = jsonlib.write( python_object ) # Converting JSON to Python python_object = jsonlib.read( json_object )
JsonUtils
import jsonutils.json # Converting Python to JSON json_object = jsonutils.json.write( python_object ) # Converting JSON to Python python_object = jsonutils.json.read( json_object )
This module is excluded from the rest of this report's testing, since it's basic JSON encoding and decoding functionality is identical to that of python-json.
python-cjson
import cjson # Converting Python to JSON json_object = cjson.encode( python_object ) # Converting JSON to Python python_object = cjson.decode( json_object )
python-json
import json # Converting Python to JSON json_object = json.write( python_object ) # Converting JSON to Python python_object = json.read( json_object )
simplejson
import simplejson # Converting Python to JSON json_object = simplejson.dumps( python_object ) # Converting JSON to Python python_object = simplejson.loads( json_object )
See also
- JSON Homepage (json.org)
- JSON Wikipedia article.
- RFC 4627: The application/json Media Type for JavaScript Object Notation (JSON), Douglas Crockford, July 2006.
- ECMA 262 (PDF), 3rd. edition (1999), aka ECMAscript/JavaScript.
- IEEE 754-1985: Standard for Binary Floating-Point Arithmetic.
- The Python JSON Catastrophe, by John Millikin (author of jsonlib), February 23, 2008.
A quick assessment of the state of the Python JSON world; written prior to this report and subsequent bug fixes by various module authors. - Choosing a Python JSON Translator,
by Jim Washington, February 2007.
[This report has several flaws, but may still be useful. Also note that it uses quite old versions of software so the speed reports are no longer accurate. For example the speed of the current version of my demjson is now many times better than what was reported here.]

