I seem to be facing a challenge:
I have a JSON list with rows of data and a JSON object. My goal is to iterate through the list and assign the rows to different objects within the JSON structure.
The first and last elements in the list are empty, followed by names and an indefinite number of "date" and "vote" pairs (refer to pastebin for clarity).
My objective is to aggregate all the votes under a specific name from the list into that particular JSON object.
How can I achieve this using JavaScript? Do I need to modify the JSON structure?
This is the initial JSON structure:
{
"subjects": [
{
"electrical_and_electronic_engineering": {
"grades": []
}
},
{
"italian_language_and_literature": {
"grades": []
}
},
{
"english_language": {
"grades": []
}
},
{
"mathematics_and_mathematical_complements": {
"grades": []
}
},
{
"motor_and_sports_sciences": {
"grades": []
}
},
{
"automatic_systems": {
"grades": []
}
},
{
"history": {
"grades": []
}
},
{
"technologies_and_design_of_electric_and_electronic_systems": {
"grades": []
}
}
]
}
And here's the corresponding array:
[ '',
'electrical and electronic engineering',
'10',
'7½',
'8½',
'5',
'9',
'7',
'4',
'7-',
'7+',
'6',
'7½',
'italian language and literature',
'6½',
'5+',
'6',
'7+',
'5',
'6½',
'english language',
'6+',
'7',
'7-',
'7½',
'7',
'7+',
'mathematics and mathematical complements',
'4½',
'9½',
'7',
'6½',
'9',
'7½',
'4',
'9',
'7½',
'7',
'8',
'8',
'motor and sports sciences',
'5',
'7',
'6',
'9',
'7',
'10',
'8',
'10',
'7',
'automatic systems',
'8',
'8½',
'10',
'10',
'8½',
'9½',
'10',
'10',
'10',
'9-',
'history',
'4',
'6',
'5½',
'technologies and design of electric and electronic systems',
's',
'7-',
'7',
'8',
'8-',
'7+',
'7½',
'6',
'6',
'8',
'6+',
'7-',
'7-',
'6',
'7',
'6',
'8½',
'' ]