0

I have the following issue: I get from my mongodb an dict document, I parse it to json and pass it trough with jinja to my html page. I try to use this json document with the renderjson package. I have tried some solutions with quote the jinja object but it's working not properly.

<div id="test"></div>
<script type="text/javascript" src="static/renderjson.js"></script>
<script>

    var str = "{{meta[1][0]}}" // meta is my list, the json object is the first element from flask
    document.getElementById("test").appendChild(
        renderjson(JSON.stringify(str))
    );
</script>

The json is valid. enter image description here

I am trying to use the renderjson package. https://github.com/caldwell/renderjson. If I use instead stringfy the parse method, nothing is displayed.

How can I pass the json to the frontend properly?

solarissmoke
  • 30,039
  • 14
  • 71
  • 73
madik_atma
  • 787
  • 10
  • 28
  • Does this answer your question? [How to pass a list from Python, by Jinja2 to JavaScript](https://stackoverflow.com/questions/15321431/how-to-pass-a-list-from-python-by-jinja2-to-javascript) – Álvaro Tihanyi Jan 26 '20 at 13:52
  • unfortunalty not. I can pass the data, but not as json. because the output is not as expected – madik_atma Jan 26 '20 at 14:53

0 Answers0