Sunday, February 03, 2013

Django: Parse JSON in my template using Javascript - Stack Overflow

Django: Parse JSON in my template using Javascript - Stack Overflow: "You could use the built-in json module:

>>> import json
>>> geodata = [ ( "Here", (1003,3004) ), ("There", (1.2,1.3)) ]
>>> json.dumps(geodata)
'[["Here", [1003, 3004]], ["There", [1.2, 1.3]]]'
You can then simply embed the resulting string inside a javascript script:

"

'via Blog this'