I implement a tree stucture for my UI with material tree, in which a new Object for this tree will be needed. this object looks like this:
[
{
name: 'Fruit',
children: [
{name: 'Apple'},
{name: 'Banana'},
{name: 'Fruit loops'},
]
}
]
but now what I have looks like this:
[
{"contact" :
{ information: {name: "abc", address:"asdfa"},
type: "phone"
value: "123212123"
}
]
expected output object looks like this:
[
{
name: 'contact',
children: [
{name: "infmormation",
children: [
{name: "address",
children: [
{name: 'absdsdc'},
]},
{name: "name",
children: [
{name: 'adasdf'},
]},
]},
{name: "type",
children: [
{name: 'abc'},
]},
{name: "type",
children: [
{name: 'Broccoli'},
]},
]
}
]
how I can create a tree object for my input object with a dynamic funcktion how create a recusive method, which can create dynmiac output method. I need your help. any solution?