5
votes

Super nub question time! I am trying to use simplejson on the google appengine. In a terminal on my machine I have simplejson installed and working. But my when I try to import it in a script running on the appengine I get an error saying no such library exists. If open the interactive console on my machine (from the link on http://localhost:8080/_ah/admin) and type "import simplejson" I get:

Traceback (most recent call last): File "/home/chris/google_appengine/google/appengine/ext/admin/init.py", line 210, in post exec(compiled_code, globals()) File "", line 1, in ImportError: No module named simplejson

Any thoughts?

2
nevermind, here it is: from django.utils import simplejsonchriscauley

2 Answers

14
votes

Look in django package:

from django.utils import simplejson as json
obj = json.loads(json_string)

Since Sdk 1.4.2 Json can be imported with the following statement:

import simplejson

Note that on Python 2.7 runtime you can use the native Json library.

10
votes

You no longer need to use the django package for simplejson on Google App Engine.

import simplejson as json

This is expecially handy for avoiding the flurry of warnings about django versions in your log file.