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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -