Here is my data structure:
{ projects: [
{ revisions: [
{ files: [] },
],
}
],
user: {}
}
Go to the jsFiddle here: http://jsfiddle.net/winduptoy/EXdDy/
I'm tyring to recursively create a JSON hierarchy structure of an object's parents and their ids. Check your console. Look at projects[0].revisions[0]._idTree, which contains the projects._id and revisions as a child of projects, just as expected. Now look at projects[0].revisions[0].files[0]._idTree, which contains projects.files as a sibling of projects.revisions, when files should be a child of projects.revisions. How do I fix this?
attachIDs(data[key][item], ...)in itself, so in the second recursive call,datais actuallydata[key][item].tree[key]is an object, I want to keep going to the deepest level of that object before I applynewKeyandnewId, it seems like that shouldn't matter, since those are just the new properties I will be applying.recurseTree()function. Hui Zheng posted a better version here: stackoverflow.com/questions/14087914/…