[英]Laravel remove backslashes from JSON response in Restful API
I'm building a restful api and i'm trying to pass image URL that stored in database我正在构建一个宁静的 api 并且我正在尝试传递存储在数据库中的图像 URL
for example, when i'm trying to pass this link to api 127.0.0.1:8000/images/123.jpg
it appearances like 127.0.0.1:8000\/images\/123.jpg
例如,当我试图将此链接传递给 api
127.0.0.1:8000/images/123.jpg
它看起来像127.0.0.1:8000\/images\/123.jpg
i tried things like stripslashes()
but nothing works我尝试了类似
stripslashes()
但没有任何效果
Controller Controller
public function companiesAll()
{
$companies = Company::where('status',1)->select('id', 'name',"image")->get();
return response()->json([$companies]);
}
Try to use:尝试使用:
return response()->json($companies, 200, [], JSON_UNESCAPED_UNICODE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.