Laravel 9 return json From Controller Example
Jul 18, 2022 . Admin
In this example, I will show you laravel 9 return json from controller. you can understand a concept of laravel 9 return json data. I explained simply step by step laravel 9 response json array. this example will help you laravel 9 json response status code.
But if you are working on Core PHP then you have to do json_encode before send output. In laravel you can do it easily like this way:
Example:public function getJsonData() { $myArray = ['id'=>1, 'name'=>'john']; return response()->json($myArray); }
It will help you...