Laravel JSON 到数组 你可能需要这样的东西

问题描述

我必须将 Laravel 通知表 data 字段中的 json 转换为 arry,

这是dd($user->notifications);上显示的数据

enter image description here

这是在邮递员中显示的响应

enter image description here

我需要在 [] 内显示有效负载,如下所示

 {
    "payload": [ {
        "title": "PHP Developer Accepted","description": "<p>This is a professional IT Job&nbsp;</p>","user_id": 54,"job_id": "01"
    }],"message": "","result": true
}

这是我的控制器索引函数

protected function index()
{
    $user = DeviceAuthenticator::getUserByAccessToken();

    foreach ($user->notifications as $notification) {
        $notifications = $notification->data;
    }

    return response()->apiSuccess($notifications); 
}

但是在我在响应之前转储 $notifications 之前,它显示为一个数组

dd($notifications);

enter image description here

解决方法

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

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

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