如何将此 Laravel 集合数组转换为 json 格式,如下所示。
//All records from users table.
$users = DB::table('users')->get();
// Required json format.
return '{
"data": [
{
"DT_RowId": "row_1",
"id": "Tiger",
"clear": "Nixon",
"fsssf": "System Architect",
"tex": "t.nixon@datatables.net",
"created_at": "Edinburgh",
"updated_at": "Edinburgh"
},
{
"DT_RowId": "row_2",
"id": "Tiger",
"clear": "Nixon",
"fsssf": "System Architect",
"tex": "t.nixon@datatables.net",
"created_at": "Edinburgh",
"updated_at": "Edinburgh"
}
],
"options": [],
"files": []
}';
很抱歉这个基本问题,但我无法将它转换成这个 jso。