Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing simplejson on the google appengine

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?

like image 970
chriscauley Avatar asked Apr 26 '10 07:04

chriscauley


2 Answers

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.

like image 87
systempuntoout Avatar answered Nov 09 '22 21:11

systempuntoout


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.

like image 30
bitmusher Avatar answered Nov 09 '22 19:11

bitmusher