You could use reduce
(the Swiss Army Knife iterator) to copy the inner objects while rearranging the name
and isMale
values. Something like this:
_(a).map(function(o) {
return _(o).reduce(function(memo, v, k) {
if(k === 'age') {
# Copy 'age' through as-is
memo[k] = v
}
else {
# Assume the rest is name:boolean so bust it apart
memo.name = k;
memo.isMale = v;
}
return memo;
}, { });
});