Hi.
I'm implementing an API Server w/ Laravel which should return JSON...so it's fine, that the framework automatically support this. My problem is, that Laravel returns escaped data as soon as unicode characters (like german umlauts) will be used.
My host application sends stuff like this:
{"id": "53SEDXAF", "name": "Testhülse"
My API Controller simply return that stuff:
// return status
return [
'status' => 'success',
'data' => Request::all(),
];
If I take a look at the response (e.g. using Fiddler), the data value will be returned using escape characters:
{"status":"success","data":{"data":{"id":"SEDXAF","name":"Testh\u00fclse"}}}
My request header looks like:
Accept: */*
Host: xyz
User-Agent: xyz
Content-Type: application/json; charset: utf-8
Accept-Charset: utf-8
Connection: Keep-Alive
Content-Length: 38
Pragma: no-cache
So, why does Laravel returned it w/ escaped characters? I thought, if I pass utf-8 as the character set in the header, the returned data will be unescaped...
I know, that I can return the JSON like this:
return response()->json(data, 200, [], JSON_UNESCAPED_UNICODE);
...but is there no other way to:
a) set this globally?
b) let Laravel return JSON dependant of what character-set has been passed in the header?
Thank you,
Marc