I have this json
[object Object],[object Object],[object Object],[object Object],,,[object Object],
You can see that there 3 undefined object. When I parse this json file I use this;
for (x=0;x<json.length;x++) {
src=json[x].file.src
list.push(src)
}
当x变为4(未定义)时,它将停止工作。如果未定义,我该怎么说脚本才能跳过此对象。
Try checking if
json[i]
is not null or undefined using if statement.或者您可以使用js函数。