{““详细信息":"JSON解析错误-预期值:第1行第1列(字符0)"} [英] { "detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)" }

查看:69
本文介绍了{““详细信息":"JSON解析错误-预期值:第1行第1列(字符0)"}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用django-restframework,我在项目中使用邮递员POST json数据,但出现类似标题的错误,我设置了raw和application/json,这是邮递员的代码.

I am using django-restframework, I use postman POST json data to my project but I got the error like tittle, I have set raw and application/json here is the code from postman.

POST /account/post/reply/ HTTP/1.1
Host: localhost:8000
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: a0c7bd93-631e-4c7a-8106-87f018eaf7da

{
    "user": "michael",
    "userid": "1",
    "ihelpid": 6,
    "tittle": "6",
    "info": "6",
    "label": "3",
    "tel": "dxy970525",
    "picture1": null,
    "picture2": null
}

我的代码真的很简单,就像:

my code is really easy only like :

from rest_framework.parsers import JSONParser,ParseError

class ReplyViewSet(viewsets.ModelViewSet):
    """
    This viewset automatically provides `list` and `detail` actions.
    """

    pagination_class=PageNumberPagination
    queryset = Forum_reply.objects.all()
    serializer_class = ReplySerializer

    #filter
    filter_backends = (DjangoFilterBackend, )
    filter_fields = ['postID',]
    def create(self, request, *args, **kwargs):
        print(request.data)
        data = JSONParser().parse(request)
        return HttpResponse("ok")

使用视图集后,会发生此错误,我已经在外壳上打印了它,但这没问题

After I use viewsets,this error occur,I have print it on shell but it is no problem

推荐答案

就我而言,我没有在数据中发送正确的json.所以请检查一下.

In my case, i was not sending a correct json in the data. So please check that.

这篇关于{““详细信息":"JSON解析错误-预期值:第1行第1列(字符0)"}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆