I have a string array like this and trying to build a tree hierarch grouped with . notation. i tried using recursive function and "set" function from lodash but could not get expected result.
let stringArray = [
'catalog.product.name',
'catalog.product.description',
'catalog.product.status',
'catalog.product_attribute_set.name'
'catalog.product_attribute_set.type'
]
my expected result is like this
[
{
"value":"catalog",
"label":"catalog",
"children":[
{
"value":"product",
"label":"product",
"children":[
{
"value":"name",
"label":"name"
},
{
"value":"description",
"label":"description"
},
{
"value":"status",
"label":"status"
}
]
},
{
"value":"product_attribute_set",
"label":"product_attribute_set",
"children":[
{
"value":"name",
"label":"name"
},
{
"value":"type",
"label":"type"
}
]
}
]
}
]