[{
"header": "API",
"value": "hello"
},
{
"header":"API",
"value":"yellow"
},
{
"header":"Other",
"value":"yallow"},
{
"header":"other",
"value":"othertt"
}
]
I have a list of objects with headers and values, and I want to restructure it so that all values with the same header are grouped together under one object. The output I'm aiming for is to have each unique header along with an array of corresponding values. Here's what I want to achieve from the initial list in TypeScript:
[
{
"header": "API",
"data": [
{
"value": "hello"
},
{
"value": "yellow"
}
]
},
{
"header": "other",
"data": [
{
"value": "yallow"
},
{
"value": "othertt"
}
]}
]