I have an object like this:
"1": "test1"
"1.1": "test2"
"1.1.1": "test3"
"1.2": "test4"
"2": "test5"
and I would like to create an array like this:
"data": [
{"data": "test1",
"children": [
{"data": "test2",
"children": [{"data": "test3"}]},
{"data": "test4"}]},
{"data": "test5"}
]
I began to loop the list and split the keys with a dot.
I thought maybe I could first build an returnArray[splitedkey[0]][splitedkey[1]] but I dont know how many levels my list has.
Has anyone an idea how to solve this?