Here is an example of a JSON object:
[
{
"venueId": "10001",
"items": [
{
"venueId": "10001",
"locationId": "14",
"itemCode": "1604",
"itemDescription": "Chef Instruction",
"categoryCode": "28",
"categoryDescription": "Food Instructions",
"qty": 0,
"saleValue": 0,
"saleDatetime": "0001-01-01T00:00:00",
"timeToLive": 0
},
... (more item details)
]
}
]
I am looking to rearrange this data into a new JSON object where it is grouped by id and then by category code. The desired format is like the following structure:
{
'1': {
'555': [{ itemCode: '456'}, { itemCode: '457'}, { itemCode: '458'}]
}
}
Is there a straightforward method to achieve this using lodash, plain JavaScript, or any available NPM package? This task is similar to another query found here: JavaScript group data into tree view 2 levels deep but with the distinction that the third level involves an array of objects.