JSONDecodeError,在Django中使用json.loads时

时间:2017-11-29 14:12:07

标签: json django django-views

JSONDecodeError,在Django中使用json.loads时。

POST数据

  

(b'csrfmiddlewaretoken = ikpUI4vMMbYivTby6FUkXRGNXisF6Cgq5eRnYvqoxRoyfAkwiP5GlsBj”   b'jVlh3Va4&安培; pergunta%5B1%5D%5Bitem%5D%5B1%5D =安培; pergunta%5B1%5D%5Bitem%5D%5B2%5D =”   B '&安培; pergunta%5B2%5D%5Bitem%5D%5B3%5D =安培; pergunta%5B2%5D%5Bitem%5D%5B4%5D =安培; pergunt'   B'A%5B2%5D%5Bitem%5D%5B5%5D =安培; pergunta%5B2%5D%5Bitem%5D%5B6%5D =')

def post(self, request):

    data = json.loads(request.body)
    pprint(data)
    return HttpResponse(data)

输出错误

  

/

中的JSONDecodeError      

请求方法:POST请求URL:http://localhost:8000/rma/ Django   版本:1.11.7异常类型:JSONDecodeError异常值:
  期望值:第1行第1列(char 0)例外   位置:/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py   在raw_decode中,第357行Python   可执行文件:/ Users / marcelowanderley / Python-Compare / bin / python Python   版本:3.6.2

0 个答案:

没有答案