I'm working with HighCharts and having a little trouble getting the color variable to work so it alternates colors.
Here is my returned JSON array:
[{"y":5,"color":"colors[0]","drilldown":{"name":"June","categories":["Fictional Hospice","Virtue Hospice"],"data":[4,1],"color":"colors[3]"}}
I need to remove the double quotes just from the colors[0]
and the colors[3]
part in order for it to work.
How do I go about doing this?
Thanks!
If you want to use references of the colors array inside JSON, that's not possible.
I would rather just use 0 and 3 in the color
property, and then, after decoding, use colors[myJSON.color]
to get the right value out of the color
property.
So, your JSON will look like this:
{"y":5,"color": 0,"drilldown":{"name":"June","categories":["Fictional Hospice","Virtue Hospice"],"data":[4,1],"color": 3}}
And when you want to get the right color, just use colors[jsonObject.color]
instead of just jsonObject.color
if you decoded your JSON string into jsonObject