//json encode
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
//now decode
$response = json_decode($response->getContent()) ;
return response()->json($array, 202,
[
'Content-Type' => 'application/json',
'Charset' => 'utf-8'
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
$json = json_decode($json, true);
print($json['username']);
//Get output from your browser network.
return response()->json([$laravelVariable]);
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
return Response::json([
'hello' => $value
], 201); // Status code here
return response()->json($array);
Route::get('/status', function () {
return response(["success" => true])->header('Content-Type', 'application/json');
});
public function getOrgById(Request $request){
// do something here...
return response()->json(array('foo' => 'bar'));
}
$report=json_encode(Teacher::with('students')->get());
return view('admin.index',compact('report'));