1
simplejsonを使用してJSON文字列を解析しようとしています。何らかの理由で、私はsimplejson.loadsを使用するときに、私は次のエラーを受け取る場合:Django simplejsonエラー
ERROR:root:Exception in request:
Traceback (most recent call last):
File "C:\django\lokus_web_new\django\core\handlers\base.py", line 111, in get_
response
response = callback(request, *callback_args, **callback_kwargs)
File "C:\django\lokus_web_new\mobile\views.py", line 13, in entry_ajax
test = simplejson.loads(entry_param)
File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson
\__init__.py", line 388, in loads
return _default_decoder.decode(s)
File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson
\decoder.py", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson
\decoder.py", line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
INFO:root:"POST /entry_ajax/ HTTP/1.1" 500 -
JSON文字列は、ネイティブjavscript JSON.stringify関数によって生成され、次のようにあるされている。
{'type':'basic','id':'156','payload':{'text':'asd'}}
ビューのコードは次のとおりです。
def entry_ajax(request):
entry_param = str(request.POST)
test = simplejson.loads(entry_param)
return HttpResponse(test['type'])
どのような考えですか?
必要な読書:http://json.org/ –
そして、私のほとんどの時間は狂ったように二重引用符で囲まれています。ありがとう、それはそれを修正した。 – ewoodrich