我有一个像这样的结果
[
{"courseStarted" :[
{"CategoryName":"CategoryName","courseName" :"Equipment Course", "seriesName": "Free Education", "courseDetails" :[
{"totalLessons" :"2", "NoLessonComplete":"1", "lastviewed":"date", "lessonDetails":[
{"lessonId":"342367","quiz":"quizReady"},
{"lessonId" :"345345", "quiz":"quizReady"},
{"lessonId":"435435","quiz":"quizReady"},
{"lessonId":"4234234", "quiz":"quizFailed"},
{"lessonId":"4234234","quiz":"quizPassed"}
]}
]}
]},
{"courseStarted" :[
{"CategoryName":"CategoryName","courseName" :"Equipment Course1", "seriesName": "Free Education1", "courseDetails" :[
{"totalLessons" :"21", "NoLessonComplete":"11", "lastviewed":"date1", "lessonDetails":[
{"lessonId":"3423671","quiz":"quizReady"},
{"lessonId" :"3453451", "quiz":"quizReady"},
{"lessonId":"4354351","quiz":"quizReady"},
{"lessonId":"42342341", "quiz":"quizReady"},
{"lessonId":"42342341","quiz":"quizPassed"}
]}
]}
]}
]
从这个json输出如何使用$ .each函数访问lessonId的值。
答案 0 :(得分:1)
$.each(data, function(){
// Print course name
console.log(this.courseStarted[0].courseName);
$.each(this.courseStarted[0].courseDetails[0].lessonDetails, function(){
// Print lesson id
console.log(this.lessonId);
});
});