What are the differences between json and simplejson Python modules?

Lakshman Prasad picture Lakshman Prasad · Apr 3, 2009 · Viewed 122.3k times · Source

I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library?

Answer

Devin Jeanpierre picture Devin Jeanpierre · Apr 3, 2009

json is simplejson, added to the stdlib. But since json was added in 2.6, simplejson has the advantage of working on more Python versions (2.4+).

simplejson is also updated more frequently than Python, so if you need (or want) the latest version, it's best to use simplejson itself, if possible.

A good practice, in my opinion, is to use one or the other as a fallback.

try:
    import simplejson as json
except ImportError:
    import json