title: Accessing json data in flask html page
body: <p>I have a Python/Flask application. In views.py I'm querying a database and returning a pagination object to the html page for rendering. The model object returned here includes a name attribute which is accessed like so on the HTML page:</p>
  
  <pre><code>{% for item in passed_items.items %}
      {{item.name}}
  {% endfor %}
  </code></pre>
  
  <p>This outputs correctly. The object ALSO has an attribute which is JSON encoded. I'm unable to access this data correctly.</p>
  
  <pre><code>{% for item in passed_items.items %}
      {{item.json}}
  {% endfor %}
  </code></pre>
  
  <p>Will output all of the JSON correctly, but I can't access any specific information within the JSON. For example, item.json will output:</p>
  
  <pre><code>{"location":"here", "city":"there"}
  </code></pre>
  
  <p>But I am unable to access specific information such as location or city. I know the JSON is encoded correctly because I copy and pasted it into a python terminal and was able to access it. For some reason it seems like the python isn't recognizing the data outputted as a dict or as JSON. Here's what I've tried:</p>
  
  <pre><code>{% for item in passed_items.items %}
      {{item.json["location"]}}
      {{item.json['location']}}
      {{item.json.location}}
  {% endfor %}
  </code></pre>
  
  <p>None of these gave any output. Any tips on how to access this data? Or how to get it recognized as a dicitonary or JSON? I feel like I've spent way too much time trying to access a simple JSON object here, haha.</p>
  
  <p>Thanks for the help!</p>
  
  <p>Edit: I've confirmed through typing:</p>
  
  <pre><code>{% for json in item.json %}
      {{json}}
  {% endfor %}
  </code></pre>
  
  <p>That it is just treating each character as an element and not recognizing it as a dictionary or JSON format. That for loop outputs each character individually instead of the key/value pairs I want.</p>
  
  <p>Edit2: Thanks guys, yeah I used json.loads() in my views.py to process the JSON first. Then I'm able to access it fine in the html page later on. Appreciate the help!</p>