I'm trying to get the length of many nested objects with dynamic keys in an array as the below:
Input:
{
"a": {
"deptAS": [
{...}
],
"deptDr": [
{...},
{...},
{...},
{...},
{...},
{...}
],
"deptES": [
{...},
{...}
],
"deptGW": [
{...
}
]
},
"b": {
"deptDr": [
{...},
{...},
{...},
{...},
{...}
],
"deptES": [
{...},
{...},
{...},
{...}
],
"deptLU": [
{...},
{...}
],
"deptSR": [
{...},
{...}
]
},
}
Which would return:
"a": {
"deptAS": 1,
"deptDr": 6
"deptES": 2,
"deptGW": 1
}
"b": {
"deptDr":5,
"deptES":4,
"deptLU":2,
"deptSR":2,
}
I've tried various .map and lodash functions but can't get the data out in the format required, but I suspect the solution is very simple.
There is access to Lodash in the project already so that can be used