I am trying to convert a python dict to a Javascript dict. As far as I understood I have to convert the python dict to Json, which I can convert to a Javascript Object
view.py
jsonheaderdict = json.dumps ( headerdict)
{{jsonheaderdict}} in template results in
{"F 1": ["BBBB", "AAAAA"], "F 2": ["ASDASD"], "F 3": ["QWEQWE"]}
and my js looks like this
$(".dict").click(function () {
alert("first alert");
var result = JSON.parse(jsonheaderdict);
alert(result);
});
The first alert shows, the second one doesn't. What am i missing? Already tried var result = jQuery.parseJSON(jsonheaderdict); which didnt work either.
I searched for similar question but didnt find any soultion that worked for me.
EDIT
For a better understanding how jsonheaderdict is created in my view:
headerdict = dict()
for d in projectdescriptors: #list of objects called descriptors
dp = projectprojections.filter(descriptor=d) #list of objects connected to descriptors
parray = []
for p in dp:
parray.append(p.name)
headerdict[d.name] = parray
alertall three entries ? what should thesecond alertshow ?