JSON is appearing as unicode entities in Jinja2 template
django, jinja2, json, python
Solution
You must filter the value through the `safe` filter to tell jinja2 that it shouldn't apply any other filters to the output. In jinja2 syntax this would be:
{{ jsonData | safe }}
Note that since you are calling `json.loads` you actually do not have json data anymore, you have a python list object. Thus when it is serialized it's the same as calling `unicode(['dogs', 'cats'])` which is going to give you your `u` prefix. You might not want to actually parse the json data, or you'll need to turn the list into a string manually instead of having jinja2 do it for you.
Problem
I using Jinja2 with webapp2. Jinja2 encodes all 'context' data into unicode as their doc says. This is proving problematic when I try to insert a json string into the the template: ``` jsonData = json.loads(get_the_file('catsJson.txt')) ``` I pass jsonData to template and I'm able to loop it successfully but when I insert a json element into HTML, it looks like this: ``` <option value='[u'dogs', u'cats']'> ``` I want it to look like this (as it is in the original json string): ``` <option value='["dogs", "cats"]'> ``` Any suggestions?