我有一个带有数字的表,但它们存储为字符串,所以我尝试使用函数 parseFloat 将其转换为整数表。但是,无论我如何执行 for 循环,它都会给我一个空白表。我可以解析该行,它会给我一个 int。我也可以解析单个 int,但似乎无法解析行或表格。这是我到目前为止所拥有的。这只是试图转换一行。我为整个表尝试了两个 for 循环,但也没有用。谢谢。
var c =[];
var entries = $.parseJSON('<?php print(json_encode($try, true)); ?>');
for (var j = 0; j < 12; j++)
{
for (var i = 0; i < 7; i++)
{
c [j][i] = parseFloat(entries[j][i]);
}
}
alert(c);
这里是条目 json 编码 [["-248","-163","-455","-1413","-1294","-1296","-1089"],["-172"," -219","-1186","-1368","-1480","-1079","-845"],["-98","-198","-703","-996" ,"-1100","-585","-616"],["-116","-241","-498","-642","-704","-354","- 430"],["-137","-117","-264","-525","-533","-269","-476"],["-12","87" ,"-257","-463","-551","-302","-535"],["170","61","-250","-472","-659" “-220”,"-605"],["159","96","-234","-513","-617","-196","-710"],["185","117" ,"-272","-521","-610","-258","-798"],["208","95","-234","-534","-696" ,"-280","-854"],["192","151","-188","-641","-739","-279","-957"],["249 ","223","-235","-684","-763","-339","-978"]]-798"],["208","95","-234","-534","-696","-280","-854"],["192","151"," -188","-641","-739","-279","-957"],["249","223","-235","-684","-763"," -339","-978"]]-798"],["208","95","-234","-534","-696","-280","-854"],["192","151"," -188","-641","-739","-279","-957"],["249","223","-235","-684","-763"," -339","-978"]]