I am faced with a massive json file that has the following format:
name: 'xxx',
worth: [123, 456, 789]
children: [
{name: 'xxx',
worth: [987, 654, 321],
children: [
{name: 'xxx',
worth: [213, 546, 879],
children: []}
},
{name: 'xxx',
worth: [987, 654, 321],
children: [
name: 'xxx',
worth: [213, 546, 879],
children: []
}],
]
The depth of children can go up to 10 layers deep. I have developed an angular component that displays the name and worth while taking the children as an Input to recursively call itself with their respective names and worth. However, I encounter maximum stack size errors using this method.
I am struggling with how to design a function that can iterate through this json until the children array is empty, displaying the name and worth of each node along the way. While recursion seems like the logical choice for this task, I am having trouble implementing it...