There is data returned from server containing an array of strings as hierarchy like this:
[
"house.bedroom.bed",
"house.kitchen.spoon",
"house.kitchen.knife",
"house.bedroom.sofa",
"house.bedroom.tv",
"plants.trees",
"house.birds.parrot.grey"
...]
how do i create a tree data structure out of it to make Output the data in tree form.
like this:
root
house
bedroom
bed
sofa
tv
kitchen
spoon
knife
birds
parrot
grey
plants
trees
what is the most simple way to do so ?
and is there any way to reverse it ? for example of asked knife i want to return house.kitchen.knife
thanks in advance