我在Html / Javascript编码, 我有一个包含列表的JSON:" Intervenant"在" Intervenant"的每一项中他们有一个名为" ListCoursa"
这里是JSON:
{
"Intervenant": [
{
"name": "John Doe",
"dateOfBirth": "1980-01-02T00:00:00.000Z",
"registered": true,
"ListeCoursa": [
{
"cours": "Cardio",
"Date": "2016-05-02T00:00:00.000Z",
"Horaire": "9-11",
"Semaine": "1"
},
{
"cours": "Flex",
"Date": "1980-05-02T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "1"
},
{
"cours": "Basic",
"Date": "2016-05-03T00:00:00.000Z",
"Horaire": "18-20",
"Semaine": "1"
},
{
"cours": "Flex",
"Date": "1980-05-04T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "1"
},
{
"cours": "Cardio",
"Date": "2016-05-09T00:00:00.000Z",
"Horaire": "9-11",
"Semaine": "2"
},
{
"cours": "Flex",
"Date": "1980-05-09T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "2"
},
{
"cours": "Basic",
"Date": "2016-05-10T00:00:00.000Z",
"Horaire": "18-20",
"Semaine": "2"
},
{
"cours": "Flex",
"Date": "1980-05-11T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "2"
}
]
},
{
"name": "John Doe2",
"dateOfBirth": "1980-01-02T00:00:00.000Z",
"registered": true,
"ListeCoursa": [
{
"cours": "Cardio",
"Date": "2016-05-01T00:00:00.000Z",
"Horaire": "10-12",
"Semaine": "10"
},
{
"cours": "Flex",
"Date": "1980-05-02T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "10"
},
{
"cours": "Basic",
"Date": "2016-05-03T00:00:00.000Z",
"Horaire": "18-20",
"Semaine": "10"
},
{
"cours": "Flex",
"Date": "1980-05-04T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "10"
},
{
"cours": "Cardio",
"Date": "2016-05-09T00:00:00.000Z",
"Horaire": "9-11",
"Semaine": "10"
},
{
"cours": "Flex",
"Date": "1980-05-09T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "20"
},
{
"cours": "Basic",
"Date": "2016-05-10T00:00:00.000Z",
"Horaire": "18-20",
"Semaine": "20"
},
{
"cours": "Flex",
"Date": "1980-05-11T00:00:00.000Z",
"Horaire": "14-16",
"Semaine": "20"
}
]
},
{
"name": "John Doe3",
"dateOfBirth": "1980-01-02T00:00:00.000Z",
"registered": true,
"ListeCoursa": [
{
"cours": "Circuit",
"Date": "1980-05-22T00:00:00.000Z",
"Horaire": "8-10",
"Semaine":"210"
},
{
"cours": "Cardio-pump",
"Date": "1980-02-22T00:00:00.000Z",
"Horaire": "16-18",
"Semaine": "210"
}
]
}
]
}
我需要计算" cours"在一周内。为此我已经把变量" Semaine"在JSON中表明课程在哪一周(" Semaine":" 20"表示课程在第20周给出)。
我的问题是如何获得所有" cours"来自" Semaine:数字"在javascript?
我希望我很清楚, 感谢。
答案 0 :(得分:0)
这是一个函数,可以汇总每个semaines的所有元素:
MainActivity