当数组包含null作为值时,未定义result_data

时间:2018-08-08 12:59:19

标签: json

result.json

{"results":[{"r":"tiger88","c":"","d":"2018-08-08","t":"","data":{"special":["7452","5158","****","8915","****","8468","6824","3465","7287","8313","1125","8085","****"],"consolation":["5369","3250","****","7002","8511","4787","4797","9320","****","1197"],"main":[null,null,null],"v":"","i":"","o":""},"jackpotcash":"500.00","multiply":{"specialx":["1","1","1","1","1","3","1","1","1","1","1","1","1"],"consolationx":["1","1","1","1","1","1","1","1","1","1"],"mainx":[null,null,null]}}]}

jquery代码

$(document).ready(function(){

$.getJSON("result.json", function(data) {

        var result_data1 ='';
        $.each(data.results, function(index, value){
result_data1 += (value.data.main ? value.data.main[0] : ''); 

它声明当主数组的值为null时未定义result_data1。因为null不是“ null”?我该怎么解决?

0 个答案:

没有答案