How can I transform my data into a specific Tree Node format?
Is there a method (using Typescript or jQuery) to iterate through each object and its nested children, grandchildren, and so on, and modify the structure?
Current data format
{
"content": [
{
"dimension": "2019-12-13",
"subList": [
{
"dimension": "2019-12-13",
"subList": [
{
"dimension": "2019-12-13",
"subList": []
}
]
}
]
},
{
"dimension": "2019-12-13",
"subList": [
{
"dimension": "2019-12-13",
"subList": [
{
"dimension": "2019-12-13",
"subList": []
}
]
}
]
}
]
}
The expected result should look like this:
{
"content": [
{
"data": {
"dimension": "2019-12-13"
},
"children": [
{
"data": {
"dimension": "2019-12-13"
},
"children": [
{
"data": {
"dimension": "2019-12-13"
},
"children": []
}
]
}
]
}
]
}