json - Symfony use JMS Serializer with JsonResponse -
in symfony application possible use jms serializer when calling jsonresponse()
on controller`?
$response = new apiresponse(apiresponse::status_success); return new jsonresponse($response); // <-- use jms serializer
thanks.
in case of symfony 3 can use this:
$json = $this->get("serializer")->serialize($response, 'json'); return new jsonresponse($json, 200, [], true);
in case of symfony 2 don't have last argument, can use standart reponse , specify content type:
$response->headers->set('content-type', 'application/json');
Comments
Post a Comment