【发布时间】:2021-12-02 08:26:31
【问题描述】:
我正在使用 Laravel 开发一个 api,我必须在 url 中获取 json 文件的数据,这是我的代码:
public function index(){
$json_file=file_get_contents("url that I'm using");
$json_str = json_decode($json_file);
echo $json_str;
}
JSON 文件:
{
"success":true,
"clients": [
[
"name": "Tyler Durden",
"job": "leader of the ..."
],
]
}
但是当我访问调用 index() 的路由时,我得到了这个错误:
Object of class stdClass could not be converted to string
我想获得任何一对客户并保存他们,有人可以帮助我吗?
【问题讨论】: