When attempting to perform a doctrine query and serialze it to json (not using JSM, using the symfony serializer) I get the following in the json:
\"\"due\":{\"timez
You have 2 ways to get RFC3339 Datetime format ...
Option 1:
Add DateTimeNormalizer as normalizer. An example is https://symfony.com/doc/current/components/serializer.html#recursive-denormalization-and-type-safety.
Change
$normalizer = array(new ObjectNormalizer());
by
$normalizer = array(new DateTimeNormalizer(), new ObjectNormalizer());
Option 2
More simple is using "serializer" container service ... your code will look like ...
public function blahAction(Request $request)
{
$currentUser = $this->getUser();
$em = $this->getDoctrine()->getManager();
$blahs = $em->getRepository('AppBundle:blah')->findAllByStatus($currentUser,'TODO');
$response = new Response($this->get('serializer')->serialize($blahs, 'json'));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
.. or, if your prefer autowiring way (this code is unchecked)
public function blahAction(Request $request, \Symfony\Component\Serializer\SerializerInterface $serializer)
{
$currentUser = $this->getUser();
$em = $this->getDoctrine()->getManager();
$blahs = $em->getRepository('AppBundle:blah')->findAllByStatus($currentUser,'TODO');
$response = new Response($serializer->serialize($blahs, 'json'));
$response->headers->set('Content-Type', 'application/json');
return $response;
}