How to get JSON Response on Laravel ?



How to get JSON Response on Laravel ?..

Answer / surbhi

JSON response can be sent using the json method.
This method will automatically set the Content-Type header to application/json.
The json method will automatically convert the array into appropriate json response.

Example :

Route::get('json',function(){
return response()->json(['name' => 'Gandhi', 'state' => 'Gujarat']);
});

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

What is auth?

0 Answers  


What is url helper?

0 Answers  


What is redirect routes?

0 Answers  


How to use where null and where not null eloquent query in laravel?

0 Answers  


What do you maen by method spoofing in laravel 5?

0 Answers  


What are the benefits of laravel?

0 Answers  


What is use in laravel?

0 Answers  


How to install laravel?

0 Answers  


What is a service provider laravel?

0 Answers  


What is meant by Laravel - Validation ?

1 Answers  


Can you update homestead? If yes, how?

0 Answers  


What is contextual binding?

0 Answers  


Categories