Js string will be converted from the format defined for json
Let me talk about my problems, I am going to write an epidemic analysis chart, the source data is obtained from the interface, his data type must be json format, if it is their direct splicing Json string can not be used as a data source of the chart
conversion method
//先将字符串拼接成JSON
var date1="[{\"name\":\"现有确诊\",\"value\":\""+confirmedCount+"\"},{\"name\":\"现有治愈\",\"value\":\""+curedCount+"\"},{\"name\":\"现有死亡\",\"value\":\""+deadCount+"\"}]";
//然后使用eval函数,注意中间的两个单引号
var date2=eval('(' + date1 + ')');