+
+ /**
+ * Shortcut to send data serialized in json.
+ *
+ * @param mixed $data
+ *
+ * @return JsonResponse
+ */
+ protected function sendResponse($data)
+ {
+ // https://github.com/schmittjoh/JMSSerializerBundle/issues/293
+ $context = new SerializationContext();
+ $context->setSerializeNull(true);
+
+ $json = $this->get('jms_serializer')->serialize($data, 'json', $context);
+
+ return (new JsonResponse())->setJson($json);
+ }