我的工作laravel应用程序,我用JSON编码格式进行保存我的数据无法从数据库数据进行解码(PHP LAravel 5.3)
{"name":"Ali","email":"[email protected]"}
它上面的显示DB文本字段
在我的方法,我得到的数据作为
function users($id, Request $request)
{
$method = $request->method();
if($request->isMethod('GET')) {
$users = DB::table('user_settings')->select('notification_setting')->first();
print_r($notification_smtp);
die;
return view('setting/user');
}
}
下面是代码的输出上面:
stdClass Object ([notification_setting] => {"name":"Ali","email":"[email protected]"})
如果我尝试解码它,它提供了一个错误的json_decode第二个参数应字符串对象传递
我怎样才能得到这种格式的响应?
stdClass Object ([name] => Ali [email] => [email protected])
我怎么可能做到这一点?
你可以发布使用JSON解码的声明? – Samir
它表示为json_decode()期望参数1是字符串,对象是 –
是的,我们需要的是您在代码中用于解码JSON的方法/语句。 – Samir