Database
[{attributes:[{_id:1,parameter:{_id:9,parameter:"HOMEROOM"},percentage_allocation:28},{_id:1,parameter:{_id:8,parameter:"PERFORMANCE"},percentage_allocation:38},{_id:100,parameter:{_id:300,parameter:"ANOTHER"},percentage_allocation:380}]}]
Query
db.collection.aggregate([{$unwind:"$attributes"},{$group:{_id:"$attributes._id",parameters:{$push:{_id:"$attributes._id",parameter:"$attributes.parameter",percentage_allocation:"$attributes.percentage_allocation"}}}},{$group:{_id:"$_id",attributes:{$push:"$$ROOT"}}}])