Laravel 5 - problem with UTF-8 in a json response

Posted 3 years ago by oriceon

Hello, I`m playing with some utf-8 strings in a ajaxcontroller and i get an error: The Response content must be a string or object implementing __toString(), "boolean" given

$address = ['şâţ' => 1];

$response = response()->json($address);
$response->header('Content-Type', 'application/json');
$response->header('charset', 'utf-8');

return $response;

Anyone know a fix for that? Thanks!

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.