Laravel JSON验证因邮递员而失败

问题描述

我正在使用邮递员向我的Laravel API发送发帖请求。

{
    "title" : "abc","body" : [
        {"type":"paragraph","data":{"text":"aSADAd"}},{"type":"header","data":{"text":"Heading......","level":2}},{"type":"paragraph","data":{"text":"This is a para"}},{"type":"list","data":{"style":"ordered","items":["ABC","XYZ"]}}
    ],"status" : 1
}

body字段是JSON数据字段-编辑器js的JSON.stringify输出。

我的laravel验证规则是-

$validator = Validator::make($request->all(),[
            'title' => 'required|string|max:255','body' => 'required|json','status' => 'required|boolean'
        ]);

但是我遇到了这个错误-

{
    "validation_error": {
        "body": [
            "The body must be a valid JSON string."
        ]
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)