So I'm passing a JSON object to a jinja2 template. The object is named 'markers' and it contains this data:
{'markers': [{'marker_id': 1, 'lat': '-33.8653882', 'lng': '151.216084'},
{'marker_id': 2, 'lat': '49.15987639', 'lng': '5.38442310'}]}
When I print the object in a p tag it appears fine, as so:
<p>{{markers}}</p>
displays:
{'markers': [{'marker_id': 1, 'lat': '-33.8653882', 'lng': '151.216084'},
{'marker_id': 2, 'lat': '49.15987639', 'lng': '5.38442310'}]}
but when i try and pass {{markers}} into my javascript at the bottom of the page it appears like this
<script>
var json = {'markers': [{'marker_id': 1, 'lat': '-33.8653882', 'lng': '151.216084'}, {'marker_id': 2, 'lat': '49.15987639', 'lng': '5.38442310'}]};
</script>
i dont know what to search for and i want to know why this is happening and how to stop it.
The object is generated by a function in my python script
def get_marker(conn):
JSONobj = { "markers" : [] }
cur = conn.cursor(MySQLdb.cursors.DictCursor)
cur.execute("SELECT * FROM marker")
data = cur.fetchall()
for row in data:
JSONobj["markers"].append(row)
return JSONobj