title: Flask Jinja2 - Parse JSON
body: <p>I'm trying do display some JSON results in a Jinja2 HTML Template, but it returns either an empty page, or every character of the JSON on a new row, or every character with spacing.</p>
  
  <p>The object that I'm sending to Jinja2 Template looks like this:</p>
  
  <pre><code>[
    {
      "name": "John",
       "lastname": "Smith", 
       "age": 22, 
       "likes": [
         {"fruits": 
           ["bananas", "oranges"]
           }, 
         {"sweets": 
           ["chocolate"]
           }
         ]
       }
     ]
  </code></pre>
  
  <p>To send the JSON object to the Jinja2 template I use:</p>
  
  <pre><code>render_template("report.html", items=items)
  </code></pre>
  
  <p>On the Jinja2 Template HTML if I use <code>{{ items }}</code> it displays the full object as text.
  If I'm trying to get the <code>{{ items['name'] }}</code> it will not display anything on the page, the page will be completely empty.</p>
  
  <p>I have also tried </p>
  
  <pre><code>{% for x in items %}
  {{ x }}
  {% endfor %}
  </code></pre>
  
  <p>and it only displays the same "text" but with spacing:
  <code>[ { " n a m e " : "J o h n " [...]</code></p>
  
  <p>In the HTML file, I'm trying to do something like:</p>
  
  <pre><code>&lt;div id="name"&gt;{{ items['name'] }}&lt;/div&gt;
  </code></pre>
  
  <p>How can I display the objects within the JSON object I'm passing to Jinja2?</p>