When working with Django (2.2), my goal is to send a JSON response in this format:
return JsonResponse(data, safe=False)
Within the data
object, there is a value that looks like this:
"unit": "\u33A5"
(cubic meters).
However, when I attempt to display this value on my HTML page using JavaScript, I end up seeing the literal representation instead of the cubic meters symbol.
Unfortunately, I cannot provide the exact JavaScript code since this symbol is meant to act as a y-axis label for an ECharts graph. But I have tried something along these lines:
yAxis: {
type: 'value',
name: data.unit,
nameLocation: 'middle',
},
If I replace data.unit
with the hardcoded "\u33A5" within the options, the cubic meters symbol displays correctly.
So, my question is: How can I properly serialize or display JavaScript symbol codes when utilizing Django's JSON responses?