I have an Ember array that looks something like this:
Once flattened, it looks like this:
This is my function:
function flatten(parent) {
return parent.reduce(function(sum, item) {
var itemVal = get(item, 'value');
if (isArray(itemVal)) {
sum = sum.concat(flatten(itemVal));
} else {
sum.push(item);
}
return sum;
}, []);
}
But it doesn't seem to work for this array which is 2 levels deep and has no value:
The root level is CONN_INFO -> CFG_SWITCH --> 412 which has no value. I would like to display the flattened array with something like this nested within Class:
key: "CONN_INFO"
value: "{CFGSwitch: {412: {}}}"
Aucun commentaire:
Enregistrer un commentaire