-2

This is the dictionary that I have given for the json.dumps in my views.py

{1: {'status': u'up', 'count': 8}, 2: {'status': u'down', 'count': 12}}

I have to use this in my javascript. I have tried the following way but not working for me.

var mydata = json.loads({{indexdata}});

can anyone please help me with this?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Suresh Kota
  • 134
  • 1
  • 2
  • 8

2 Answers2

0

java script interprets things like you've posted as an object. you don't need any conversion.

var myObj = {a : { b : 5 }}

is a valid js object

Michael
  • 1,027
  • 10
  • 22
0

Try this:

var mydata = {{indexdata}};
friedi
  • 4,350
  • 1
  • 13
  • 19