I have a javascript list in the form of:
var list = [{id:1, data: "string", list: [
{id:2, data: "string", list: [
{id:3, data: "string", list: null}]},
{id:4, data: "string", list: null}]}];
And I want it to be in the form of:
var list = [{id:1, data: "string", list: \\ original nested list or null, I don't care},
{id:2, data: "string", list:},
{id:3, data: "string", list:},
{id:4, data: "string", list:}];
I have access to underscore.js, but I haven't been able to produce the output I want.
I tried using a combination of _.flatten and _.pluck to get the underlying list, but I also need the id property so this doesn't work.
My guess is that I need to map a function, but I'm kind of lost on the issue right now.
Could anybody help me with this?