我有以下 JSON:(它为你简化了一点)
{ returnJSON = {
studentDataVOs = {
finalGrades = (
{
grade = A;
percent = 100;
sectionid = 7744;
reportingTermId = 801;
},
{
grade = B+;
percent = 89;
sectionid = 7745;
reportingTermID = 801;
});
reportingTerms = (
{
id = 801;
title = S1;
},
{
id = 802;
title = S2;
});
sections = (
{
id = 7744;
termID = 801;
courseTitle = Physics;
courseCode = 88A;
},
{
id = 7745;
termID = 801;
courseTitle = Government;
courseCode = 90B;
});
};
};
}
我正在使用 Appcelerator Titanium 构建一个应用程序,该应用程序显示一个表格视图,其中的数据有望显示以下内容:
物理 (88A) - S1(等级:A,100%)
政府 (90B) - S1(等级:B+,89%)
...等等...
我设置了表格视图,以下代码从部分中提取数据并将其放在表格视图的标签中:
var response = JSON.parse(response);
var sections = response.returnJSON.studentDataVOs.sections;
for (i=0;i<sections.length;i++) {
var courseName = sections[i].courseTitle;
var courseCode = sections[i].courseCode;
}
我无法弄清楚如何获取每个班级的成绩和学期名称。如您所见,每个部分的数据都包含一个 ID 和 termID,它们将我引导到 finalGrades 和 reportingTerms 中包含 ID 或 termID 的部分,我需要在其中获取最终成绩、百分比和学期标题。
谁能帮我这个?我已经尝试了两天试图解决这个问题......