php json编码中的双引号

时间:2015-06-04 13:38:27

标签: php json

我文件中的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编码时,它会给出带双引号的输出。

1 个答案:

答案 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);