I am getting a json structure given below form an api which contains paths of related children in an array form . for example here is my json structure
[
{
"name": "Children C1",
"path": [
"A",
"B",
"C"
]
},
{
"name": "Children C2",
"path": [
"A",
"B",
"C"
]
},
{
"name": "Children C3",
"path": [
"A",
"B",
"C"
]
},
{
"name": "Children B1",
"path": [
"A",
"B"
]
},
{
"name": "Children B2",
"path": [
"A",
"B"
]
},
{
"name": "Children A1",
"path": [
"A"
]
},
{
"name": "Children E1",
"path": [
"D",
"E"
]
}
]
Here path is the route for a childeren. For example first object means -A -B -C - Childeren C1
and so on . I am using tree view library which requires only this structure
var tree=[
{
'Name': 'A',
'children': [
{
Name: '',
children: [
]
}
]
}
]
and so on. I want to convert my path structure to tree. Need help I can I achieve this with plain javasript.
Thanks