I want to use json.dumps()
to pretty print JSON inside my app.
Currently, my template is set up like this:
<table>
{% for test in list_of_decoded_json %}
<tr>
<td><pre>{{ test|safe }}</pre></td>
</tr>
{% endfor %}
</table>
Where test
is the decoded JSON string. However, this implementation only prints the JSON strings in one line.
Knowing that jinja2 doesn't support the json.dumps()
function in-template, how can I get the pretty printed layout that I want?
json.dumps()
function likereturn render_template('index.html', dumps=dumps)
...No I didn't say this can solve your problem.