title: Empty JSON Array when using @Groups annotation with JMS Serializer and FOSRestBundle v2.1
body: <p>I'm trying to use the <code>@Groups</code> annotation to serialize my data but I'm just receiving an empty array.</p>
  <p>I've tried using <code>@Serializer\Expose</code> on the fields I want to show up, but then they show up everywhere and ignore the groups.</p>
  <p>From what I've read I'm pretty sure that I should only need to use the <code>@Groups</code> annotation but I just end up with this (there are two schedule entities):</p>
  <pre><code>{
    &quot;schedules&quot;: [
      {},
      {}
    ]
  }
  </code></pre>
  <p>There seems to have been a change to how this is supposed to work, I've found examples for previous versions FOSRestBundle, I just have not been able to port them over to the new version.</p>
  <p>From what I understand you can set groups in the serializer context and use that to set the views context, but I've had no luck with that.</p>
  <p><a href="https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/UPGRADING-2.0.md" rel="nofollow noreferrer">https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/UPGRADING-2.0.md</a></p>
  <blockquote>
  <p>View::setSerializationContext and View::getSerializationContext have been removed. Use View::setContext and View::getContext together with the new Context class instead.</p>
  <p>Before:</p>
  <pre><code>use JMS\Serializer\SerializationContext;
  
  $view = new View();
  $context = new SerializationContext();
  $view-&gt;setSerializationContext($context);
  $context = $view-&gt;getSerializationContext();
  </code></pre>
  <p>After:</p>
  <pre><code>use FOS\RestBundle\Context\Context;
  
  $view = new View();
  $context = new Context();
  $view-&gt;setContext($context);
  $context = $view-&gt;getContext();
  </code></pre>
  </blockquote>
  <p>I'm having a hell of a time getting my head around all this, and would ever so grateful for any assistance to point me in the right direction.</p>
  <p>As well as the following I attempted to <code>use FOS\RestBundle\Controller\Annotations as Rest; </code> and
  <code>@Rest\View(serializerGroups({&quot;schedule&quot;})</code> annotation with the  on the controller, it had the same effect as I'm seeing now (<em>ie</em> none).</p>
  <p>Schedule Controller</p>
  <pre><code>use FOS\RestBundle\Context\Context;
  
  class ScheduleController extends BaseController
  {
      /**
       * @param $date
       * @return \Symfony\Component\HttpFoundation\Response
       */
      public function getSchedulesScheduleAction($date)
      {
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          list($startDate, $endDate) = $this-&gt;get('radio.utils.date_and_time')-&gt;findWeekRange($date);
          $schedules = $em-&gt;getRepository('RadioBundle:Schedule')-&gt;findByRange($startDate, $endDate);
  
          $view = $this-&gt;view(
              [
                  'schedules' =&gt; $schedules,
              ],
              200
          );
  
          $context = new Context();
          $context-&gt;setGroups([&quot;schedule&quot;]);
          $view-&gt;setContext($context);
  
          return $this-&gt;handleView($view);
      }
  }
  </code></pre>
  <p>Schedule Entity</p>
  <pre><code>use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  use JMS\Serializer\Annotation as Serializer;
  
  /**
   * Schedule
   *
   * @ORM\Table(name=&quot;schedule&quot;)
   * @ORM\Entity(repositoryClass=&quot;RadioBundle\Repository\ScheduleRepository&quot;)
   * @Serializer\ExclusionPolicy(&quot;all&quot;)
   */
  class Schedule
  {
      /**
       * @var int
       *
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
       */
      private $id;
  
      /**
       * @var \DateTime
       * @Assert\NotBlank()
       * @Serializer\Groups({&quot;schedule&quot;})
       * @ORM\Column(name=&quot;start_time&quot;, type=&quot;datetime&quot;)
  \     */
      private $startTime;
  
      /**
       * @var \DateTime
       * @Assert\NotBlank()
       * @Serializer\Groups({&quot;schedule&quot;})
       * @ORM\Column(name=&quot;end_time&quot;, type=&quot;datetime&quot;)
       */
      private $endTime;
  
  
  
      /**
       * @Assert\NotBlank()
       * @Serializer\Groups({&quot;schedule&quot;})
       * @ORM\ManyToOne(targetEntity=&quot;RadioBundle\Entity\RadioShow&quot;, inversedBy=&quot;schedule&quot;)
       */
      private $radioShow;
  
      ...
  </code></pre>
  <p>app/config.yml</p>
  <pre><code>fos_rest:
      param_fetcher_listener: true
      body_listener: true
      format_listener: true
      view:
          view_response_listener: 'force'
      routing_loader:
          default_format: json
  
  jms_serializer:
      metadata:
          auto_detection: true
  </code></pre>