title: Symfony2 JSON response returns weird UTF characters
body: <p>Here's my controller method:</p>
  
  <pre><code>  public function sendjsonAction()
    {
  
      $message = $this-&gt;getDoctrine()
      -&gt;getRepository('AcmeStoreBundle:Message')
      -&gt;findAll();
      $serializer = new Serializer(array(new GetSetMethodNormalizer()), array('message' =&gt; new 
  JsonEncoder()));
      $message = $serializer-&gt;serialize($message, 'json');    
      return new JsonResponse($message);
  
    }
  </code></pre>
  
  <p>Here's my router:</p>
  
  <pre><code>acme_store_sendjson:
      pattern:  /sendjson/
      defaults: { _controller: AcmeStoreBundle:Default:sendjson}
  </code></pre>
  
  <p>And here's what I get when I go to /sendjson/ : </p>
  
  <p><code>"[{\u0022id\u0022:1,\u0022iam\u0022:1,\u0022youare\u0022:2,\u0022lat\u0022:50.8275853,\u0022lng\u0022:4.3809764,\u0022date\u0022:{\u0022lastErrors\u0022:{\u0022warning_count\u0022:0,\u0022warnings\u0022:[],\u0022error_count\u0022:0,\u0022errors\u0022:[]},\u0022timezone\u0022:{\u0022name\u0022:\u0022UTC\u0022,\u0022location\u0022:{\u0022country_code\u0022:\u0022??</code> </p>
  
  <p>(and it goes on similarly)</p>
  
  <p>I attempt to make an ajax call (with jQuery) with the following:</p>
  
  <pre><code>$.getJSON('/app_dev.php/sendjson', function(data) {
    var items = [];
  
    $.each(data, function(key, val) {
      items.push('&lt;li id="' + key + '"&gt;' + val + '&lt;/li&gt;');
    });
  
    $('&lt;ul/&gt;', {
      'class': 'my-new-list',
      html: items.join('')
    }).appendTo('body');
  });
  </code></pre>
  
  <p>And I get a </p>
  
  <pre><code>Uncaught TypeError: Cannot use 'in' operator to search for '1549' in [{"id":1,...
  </code></pre>
  
  <p>When I change the Response type of Symfony2, I get a list of </p>
  
  <p>[Object] [Object]
  [Object] [Object]
  [Object] [Object]
  ...</p>
  
  <p>What am I doing wrong? Should I be parsing the answer to convert \u0022 to " or is my response faulty from the beginning?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I also tried by changing the controller to:</p>
  
  <pre><code>  public function sendjsonAction()
    {
  $encoders = array(new XmlEncoder(), new JsonEncoder());
  $normalizers = array(new GetSetMethodNormalizer());
  $serializer = new Serializer($normalizers, $encoders);
  
      $message = $this-&gt;getDoctrine()
      -&gt;getRepository('AcmeStoreBundle:Message')
      -&gt;findAll();
  $serializer = $serializer-&gt;serialize($message, 'json');
      return new Response($serializer);
  }
  </code></pre>
  
  <p>This time I got VALID JSON, (according to Jsonlint) buuttt the headers are not application/json... (makes sense because I am sending a Response and not a JsonResponse...) (but thats what I m trying to avoid as JsonResponse seems to be changing adding weird characters)</p>
  
  <pre><code>[{"id":1,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"},{"id":2,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"},{"id":3,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"},{"id":4,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"},{"id":5,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"},{"id":6,"iam":1,"youare":2,"lat":50.8275853,"lng":4.3809764,"msgbody":"I saw you over there what's up!"}]
  </code></pre>