有没有人让jsonpickle在google app引擎上工作?我的日志上说没有模块,但有一个模块就像你出生时一样确定。我使用的是jsonpickle 0.32。
<type 'exceptions.ImportError'>: No module named jsonpickle
Traceback (most recent call last):
File "/base/data/home/apps/xxxxx/xxxxxxxxxxxxxxxxx/main.py", line 4, in <module>
import jsonpickle发布于 2010-01-05 23:14:19
我已经成功地将django.utils.simplejson注册为json编码器/解码器。在这个真实的文件中,index.py类Pizza被编码和解码:
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import jsonpickle
class Pizza:
pass
class Example(webapp.RequestHandler):
def get(self):
jsonpickle.load_backend('django.utils.simplejson',
'dumps','loads',ValueError)
encoded = jsonpickle.encode(Pizza())
self.response.out.write( jsonpickle.decode(encoded).__class__ )
run_wsgi_app(webapp.WSGIApplication([('/', Example),],debug=True))发布于 2010-01-05 10:45:15
正如this post解释的那样,jsonpickle需要几个底层JSON模块中的一个。我将解决这个问题,如下所示--将以下几行放在需要jsonpickle的模块的顶部:
import sys
import django.utils.simplejson
sys.modules['simplejson'] = django.utils.simplejson这解决了这个问题: jsonpickle需要simplejson (作为它可以使用的JSON模块之一),但是GAE将它作为django.utils.simplejson,所以您需要适当地给它加上“别名”。
https://stackoverflow.com/questions/2003817
复制相似问题