up vote 7 down vote favorite

I have seen many a projects use simplejson module than the in builtin Standard Library json.

Also there seem to be many different simplejson modules

What are the advantages of simplejson and which implementation is good?

Why not, just use the standard builtin json module?

flag

4 Answers

up vote 15 down vote accepted

json is simplejson, added to the stdlib. Since json was only added in 2.6, simplejson has the advantage of working on more python versions (2.4+, rather than 2.6+). Also, simplejson is updated more frequently than Python is, so if you need the latest version for some reason, it's best to use simplejson itself.

A good practice, in my opinion, is to use it as a fallback.

try: import json
except ImportError: import simplejson as json
link|flag
up vote 3 down vote

The builtin json module got included in Python 2.6. Any projects that support versions of Python < 2.6 need to have a fallback. In many cases, that fallback is simplejson.

link|flag
up vote 1 down vote

Here's (a now outdated) comparison of Python json libraries:

Comparing JSON modules for Python

Regardless of the results in this comparison you should use the standard library json if you are on Python 2.6. And.. might as well just use simplejson otherwise.

link|flag
up vote 1 down vote

Another reason projects use simplejson is that the builtin json did not include its C speedups, so the performance difference is noticeable.

link|flag

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.