Below is an example of an array:
[
{
"exam" : "1",
"class": "1A1",
"rooms": "245",
"teachers": "A"
},
{
"exam" : "1",
"class": "1A2",
"rooms": "685",
"teachers": "B"
},
{
"exam" : "2",
"class": "1EM1",
"rooms": "630",
"teachers": "C"
}
]
How can I transform it into the following format? I attempted to use lodash's groupBy method but did not achieve the desired outcome.
[
{
"exam" : "1",
"classes": [
{
"class": "1A1",
"rooms": "245",
"teachers": "A"
},
{
"class": "1A2",
"rooms": "685",
"teachers": "B"
}
]
},
{
"exam" : "2",
"classes": [
{
"class": "1EM1",
"rooms": "630",
"teachers": "C"
}
]
}
]