I have a collection of string literals in an array
var selected = ['a', 'b.c', 'b.c.d', 'b.c.d.e'];
How can I create a below JSON tree structure using JavaScript? Any help would be appreciable.
[{
"title": "a",
"id": "a"
},
{
"title": "b",
"id": "b",
"children": [{
"title": "c",
"id": "c",
"children": [{
"title": "d",
"id": "d",
"children": [{
"title": "e",
"id": "e"
}]
},
{
"title": "f",
"id": "f"
}
]
}]
}
]