遍历 JSON 数组:
var questions = data.data.questionnaire.questions;
//遍历 json 数组
for (var i in questions) {
if (questions[i].type == '(单选)') {
alert('danxuan');
}
}
获取 JSON 数组长度:
function getJsonLength(json) {
var jsonLength = 0;
for (var i in json) {
jsonLength++;
}
return jsonLength;
}