[英]How to pass the dictonary object to Django-rest-framework with double quote by http.request's json parameter?
I got this error message on Django-rest-framework. 我在Django-rest-framework上收到此错误消息。
JSON parse error - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)"
}
Its cause must be single quote, but I passed the json datavia http.request method, like as below. 它的原因必须是单引号,但是我通过http.request方法传递了json数据,如下所示。
r = requests.patch('http://localhost:8000/api/xxxx,headers=self.headers, json=payload)
the payload is dictionary. 有效载荷是字典。
id = 111
paylod = {resultid:{"data":"abc","data2","def"}}
How should I handle this? 我该怎么处理? I appreciate the advise!
我很欣赏这个建议!
添加双引号以在有效负载dict中重新resultid
paylod = {"resultid":{"data":"abc","data2","def"}}
Thanks shaik moeed, I found my mistake. 谢谢shaik moeed,我发现了我的错误。 I checked the functionality on django-rest-framework with raw input form, But in this time, I use json parameter on http.request, thus I do not need consider single quote or double quote.
我用原始输入表单检查了django-rest-framework上的功能,但是在这个时候,我在http.request上使用了json参数,因此我不需要考虑单引号或双引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.