title: Using Twig to generate JSON
body: <p>I want to have a URL that returns a simple JSON object. I am trying to use Twig to generate the JSON object:</p>
  
  <pre><code>{
  "urls": [
  {% for child in page.root %}
      "{{ child.url }}"{% if not loop.last %},{% endif %}
  {% endfor %}
  ]
  }
  </code></pre>
  
  <p>The carriage returns will not remain in place though, and I keep getting a result that looks like this:</p>
  
  <pre><code>{'urls':['../ants/','../brick-report/','../the-pollution-intervention/','../barclay/','../broken-advertising/','../aldat-n-densom/','../thisisart/','../there-she-goes-again/']}
  </code></pre>
  
  <p>which Jquery will not parse with it's ajax or getJSON methods. It's totally ignoring this JSON. How might I convince Twig to put the right whitespace in place? I've looked at the manual and it only seems concerned with NOT inserting whitespace.</p>