我文件中的JSON是:
[{"name":"ltrs","data":["25","80","110","113","139","1025","1026","1027","1028","1029"]},{"name":"total","data":["3","723","19","48","3","6","14","17","15","6"]}]
我要求:
[{"name":"ltrs","data":["25","80","110","113","139","1025","1026","1027","1028","1029"]},{"name":"total","data":[3,723,19,48,3,6,14,17,15,6}]
在highchart.js
中绘制条形图所需的JSON。
当我从mysql运行php查询以获取json编码时,它会给出带双引号的输出。
答案 0 :(得分:0)
如果name = total
以下是代码尝试:
var a = [{"name":"ltrs","data":["25","80","110","113","139","1025","1026","1027","1028","1029"]},{"name":"total","data":["3","723","19","48","3","6","14","17","15","6"]}];
$.each(a, function(k,v){
if(v.name == 'total'){
$.each(v.data, function(k1,v1){
v.data[k1] = v1*1;;
});
}
});
console.log(a);