Answer the question
In order to leave comments, you need to log in
JsonResponse symfony how to use cyrillic?
when I use return new JsonResponse($data);
in the latest version of symphony, instead of Cyrillic, I get \u041f\u0430\u0448\u0430
as well as escaping slashes.
How do I write JSON_UNESCAPED_UNICODE and JSON_UNESCAPED_SLASHES for JsonResponse in symfony?
Answer the question
In order to leave comments, you need to log in
In my opinion, there is only one constant that can be passed to setEncodingOptions
$response = new JsonResponse(['message' => 'Привет!']);
$response->setEncodingOptions(JSON_UNESCAPED_UNICODE);
return $response;
In this scenario, when there are slashes, Russian letters and tags,
if not converted to UTF-8, I received
return new JsonResponse($data);
Malformed UTF-8 characters, possibly incorrectly encoded
return new JsonResponse(mb_convert_encoding($data, 'UTF-8', 'UTF-8'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question