这是我的 json,肯定合法:
{
"categories": [
{
"id": 1,
"title": "上衣类",
"products": [
{
"id": 8,
"title": "运动服",
"nums": 2,
"price": 60.00
},
{
"id": 10,
"title": "夹克衫",
"nums": 2,
"price": 60.00
}
],
"total_nums": 4,
"total_price": 120.00
},
{
"id": 5,
"title": "汽车类",
"products": [
{
"id": 63,
"title": "布艺两件套",
"nums": 5,
"price": 250.00
},
{
"id": 65,
"title": "布艺七件套",
"nums": 1,
"price": 200.00
}
],
"total_nums": 6,
"total_price": 450.00
}
],
"count_price": 570.00
}
代码如下:
public function postWashOrderinfo(Request $request){
$param = $request->all();
// 进行参数校验
$validate = new PostWashOrderinfoValidate();
if (!$validate->check($param)) {
return json($validate->getError());
}
$orderinfo = json_decode($param['orderinfo'],true);
return $orderinfo;
}
$orderinfo = json_decode($param['orderinfo'],true);
不管加不加 true 就是 null。
var_dump ($param['orderinfo']),贴出下
string(1122) "{
"categories": [
{
"id": 1,
"title": "上衣类",
"products": [
{
"id": 8,
"title": "运动服",
"nums": 2,
"price": 60.00
},
{
"id": 10,
"title": "夹克衫",
"nums": 2,
"price": 60.00
}
],
"total_nums": 4,
"total_price": 120.00
},
{
"id": 5,
"title": "汽车类",
"products": [
{
"id": 63,
"title": "布艺两件套",
"nums": 5,
"price": 250.00
},
{
"id": 65,
"title": "布艺七件套",
"nums": 1,
"price": 200.00
}
],
"total_nums": 6,
"total_price": 450.00
}
],
"count_price": 570.00
}"
你可以试下放在body里传过去
好像是这么回调
post请求最好不要使用QueryString传参。
嗯,最后改成 body 就OK 了