I've got a object a bit like this:
{
"FORD": [
{
"ManufacturerName": "FORD",
"Model": "Focus",
"Price": "12345"
},
{
"ManufacturerName": "FORD",
"Model": "KA",
"Price": "11111"
},
{
"ManufacturerName": "FORD",
"Model": "Focus",
"Price": "22222"
}
],
"HONDA": [
{
"ManufacturerName": "HONDA",
"Model": "JAZZ",
"Price": "98765"
},
{
"ManufacturerName": "HONDA",
"Model": "JAZZ",
"Price": "33333"
}
]
}
I've got this far using lodash code like this:
let myTest = _.chain(obj)
.sortBy('ManufacturerName')
.groupBy('ManufacturerName')
What I'm trying to do also also group it by Model, so result will look something like this:
{
"FORD": [
{
"Focus": [
{
"ManufacturerName": "FORD",
"Model": "Focus",
"Price": "12345"
},
{
"ManufacturerName": "FORD",
"Model": "Focus",
"Price": "12345" }
],
"KA": [
{
"ManufacturerName": "FORD",
"Model": "KA",
"Price": "11111"
}
]
}
],
"HONDA": [
{
"JAZZ": [
{
"ManufacturerName": "HONDA",
"Model": "JAZZ",
"Price": "33333" },
{
"ManufacturerName": "HONDA",
"Model": "JAZZ",
"Price": "98765" }
]
}
]
}
Thanks.