我有学生记录。我希望循环使用此JSON,并且使用undefined
SchoolRecord.classX[1]
var SchoolData = {
"SchoolRecord": {
"classX": {
"name": "Student Name 1",
"subject": {
"mathsDept": {
"subject": "Maths",
"marks": 87
},
"scienceDept": {
"subject": "Physics",
"marks": 55
},
"socialDept": {
"subject": "Social",
"marks": 95
}
}
},
"classIX": {
"name": "Student Name 2",
"subject": {
"mathsDept": {
"subject": "Maths",
"marks": 99
},
"scienceDept": {
"subject": "Physics",
"marks": 95
},
"socialDept": {
"subject": "Social",
"marks": 91
}
}
}
}
}
console.log(SchoolData.SchoolRecord);
console.log(SchoolData.SchoolRecord[0]);