How can i convert this Laravel collection array to json format like below.
//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": "[email protected]",
"created_at": "Edinburgh",
"updated_at": "Edinburgh"
},
{
"DT_RowId": "row_2",
"id": "Tiger",
"clear": "Nixon",
"fsssf": "System Architect",
"tex": "[email protected]",
"created_at": "Edinburgh",
"updated_at": "Edinburgh"
}
],
"options": [],
"files": []
}';
Sorry for the basic question,but i am unable to convert this into this jso.
@json
directive. Also you can find this in the Laravel docs: laravel.com/docs/9.x/blade#rendering-json – Joggle