I'm currently working on a recursive function to navigate through a nested JSON structure. However, I've run into an error that says:
Maximum call stack exceeded
The function I've written looks like this:
function createTreeMap (treeCatalog){
var _this = this;
_.each(treeCatalog, function (ele, inx){
if(typeof (ele) === "object"){
createTreeMap(ele);
}else{
//Here I create another JSON structure with the value as its property and set it to 1.
_this.treeMap[ele] = 1;
}
});
}
The JSON data I'm traversing through is structured as follows:
[{
"EmployeeID": 2,
"FirstName": "Andrew",
//... employee details here
children: [{
"EmployeeID": 8,
"FirstName": "Laura",
//... more employee details
}, {
//... additional employees
}]
}];
I suspect that the issue may be related to similar child property names. Is there a proper way to address this while keeping the requirement for similar child names?
Thank you for your assistance :)
UPDATE
Check out this example that demonstrates the issue I'm facing: http://jsfiddle.net/qaoapays/1/