title: Twig with Symfony 2 displaying json encoded variables different between prod and dev
body: <p>We're building a Symfony 2 application that sends some data from controller to view:</p>
  
  <h2>Controller</h2>
  
  <pre><code>$user = array(
      'configuration' =&gt; array(
          'levels' =&gt; array(
              'warning' =&gt; 0.05,
              'danger'  =&gt; 0.10,
          ),
      ),
  );
  
  return $this-&gt;render(
      'MyWebsiteBundle:Core:searchResults.html.twig',
      array(
          'userJSON'  =&gt; json_encode($user)
      )
  );
  </code></pre>
  
  <h2>View</h2>
  
  <pre><code>&lt;script language="javascript"&gt;
      user = $.parseJSON("{{ userJSON }}");
  &lt;/script&gt;
  </code></pre>
  
  <h2>Result</h2>
  
  <p>On <code>dev</code> the result looks like this and works as expected:</p>
  
  <pre><code>user = $.parseJSON("\x7B\x22configuration\x22\x3A\x7B\x22levels\x22\x3A\x7B\x22warning\x22\x3A0.05,\x22danger\x22\x3A0.1\x7D\x7D\x7D");
  </code></pre>
  
  <p>On the other hand, on <code>prod</code> the result is encoded in a different manner, thus displaying errors in console:</p>
  
  <pre><code>user = $.parseJSON("{&amp;quot;configuration&amp;quot;:{&amp;quot;levels&amp;quot;:{&amp;quot;warning&amp;quot;:0.05,&amp;quot;danger&amp;quot;:0.1}}}");
  </code></pre>
  
  <p><strong>Console Error</strong>: Uncaught SyntaxError: Unexpected token &amp;</p>
  
  <p>What generates this difference?</p>