laravel get to json code example

Example 1: convert json string to json object in laravel

$manage = json_decode($request->stdin, true);
 print_r($manage);

Example 2: how get value of json encode in laravel

$json = '{"countryId":"84","productId":"1","status":"0","opId":"134"}';
$json = json_decode($json, true);
echo $json['countryId'];
echo $json['productId'];
echo $json['status'];
echo $json['opId'];

Example 3: laravel return response json

return response()->json([
    'name' => 'Abigail',
    'state' => 'CA',
]);

Tags:

Php Example