json.parse在javascript中跳过值

时间:2016-01-14 16:31:37

标签: javascript json ajax

我正在使用格式化的JSON文本有效负载获取AJAX网络摄像头(下面的示例A)。在AJAX调用的成功函数中,我在数据有效负载上运行JSON.parse,如下所示:

var jsonified = JSON.parse( data.d );

这就是问题所在。有时,JSON.parse会跳过data.d中存在的值,因为它们在var jsonified中缺失。例如,data.d每行有30个字段,而jsonified每行有时会有17个字段,而且在几行中有20个字段。

我无法弄清楚问题出在哪里。有时,var jsonified每行具有正确的字段数,但它通常会在不进行任何代码更改的情况下恢复为缩短的版本。我尝试通过jQuery函数进行解析,该函数可以进行几次传递,然后恢复到完全相同的问题。以前有人遇到过这个问题吗? data.d和jsonified示例如下。

data.d(仅显示一行):

{"DATA":[["","SRRMAP","BTM",2015,"Lenscrafters","Name, Last","Name, Last","Name, Last",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"AIRFARE",0.00,0.00,291.84,11.50,11.00,422.70,17.00,50.00,5.50,5.50,0.00,0.00],null]}

jsonified数组中的一行:

0: ""
1: "SRRMAP"
2: "BTM"
3: 2015
4: "Lenscrafters"
5: "Name, Last"
6: "Name, Last"
7: "Name, Last"
8: 0
9: 0
10: 0
11: 0
12: 0
13: 5.5
14: 0
15: 0

0 个答案:

没有答案