将json发布到laravel 5.1问题

时间:2016-01-21 20:51:27

标签: php json laravel request laravel-5.1

我正在向laravel提交此帖子请求(来自ios使用AFNetworking,不介意语法)

{
    cart =     {
        "company_id" = 1;
        quantity = 3;
        "service_product_id" = 1;
    };
    options =     (
                {
            "company_id" = 1;
            "service_product_option_id" = 1;
            "service_product_option_value_id" = 2;
        },
                {
            "company_id" = 1;
            "service_product_option_id" = 2;
            "service_product_option_value_id" = 3;
        }
    );
}

这是laravel获取的请求,我只是让它返回调试目的的请求

public function postCart(Request $request)
{
    return $request->all();
}

和结果

{
    cart =     {
        "company_id" = 1;
        quantity = 3;
        "service_product_id" = 1;
    };
    options =     (
                {
            "company_id" = 1;
        },
                {
            "service_product_option_id" = 1;
        },
                {
            "service_product_option_value_id" = 2;
        },
                {
            "company_id" = 1;
        },
                {
            "service_product_option_id" = 2;
        },
                {
            "service_product_option_value_id" = 3;
        }
    );
}

即使传递的选项数组包含两个内部对象,它也会在laravel端被处理为6个不同的对象。为什么这样以及如何解决这个问题?

0 个答案:

没有答案