I have the following situation and I don't have any solution
I have the following view.py
def getData(request, ft):
context = {'hello': 'World',
'ABC': 123,
456: 'abc'}
dataJSON = dumps(context)
return HttpResponse(request, 'lic_usage_overview.html', {"data": dataJSON})
Now I need to assign these values to a array Object in javascript/jQuery. I tried in this way (and another 100 ways) but is not working:
<script>
var data = JSON.parse({{data|escapejs}});
for(var x in data){
console.log(x+' : '+data[x]);
}
</script>
The console give me this as result:
VM574 jquery-3.5.1.min.js:2 Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
Have anybody any idea about how to solve this problem?
Thanks