Could you assist me with transforming JSON data?
The initial structure is as follows:
[
{
"_id": "606f990042cc89060c54a632",
"number": 1293,
"date": "2021-04-08",
"__v": 0
},
{
"_id": "606e478042cc89060c54a631",
"number": 997,
"date": "2021-04-07",
"__v": 0
}
]
Once transformed, the structure should look like this:
[
{
"id": "weight",
"data": [
{
"x": "2021-04-08",
"y": 1293
},
{
"x": "2021-04-07",
"y": 997
}
]
}
]
What would be the most efficient way to achieve this transformation? Would using the lodash library or JavaScript's built-in functions be better for this task?
Any hints on how I can approach this?