Which JSON module can I use in Python 2.5?
You can use simplejson.
As shown by the answer form pkoch you can use the following import statement to get a json library depending on the installed python version:
try:
import json
except ImportError:
import simplejson as json
To Wells and others:
Way late here, but how can you write a script to import either json or simplejson depending on the installed python version?
Here's how:
try:
import json
except ImportError:
import simplejson as json
I wrote the cjson 1.0.6 patch and my advice is don't use cjson -- there are other problems with cjson in how it handles unicode etc. I don't think the speed of cjson is worth dealing with the bugs -- encoding/decoding json is usually a very small bit of the time needed to process a typical web request...
json in python 2.6+ is basically simplejson brought into the standard library I believe...