I'm stuck to construct a new multidimensional array based on this existing array object
acl:[
{
view:true,
update:true,
remove:true,
userId:1,
username:"Mike"
},
{
view:true,
update:true,
remove:false,
userId:2,
username:"Joe"
},
{
view:true,
update:false,
remove:false,
userId:3,
username:"Lim"
}
]
The new object will be constructed based on the boolean properties(if these boolean is equal to true). The new array will look like this
acl:[
{
view:[
{username:"Mike", userId:1},
{username:"Joe", userId:2},
{username:"Lim", userId:3}
]
update:[
{username:"Mike", userId:1},
{username:"Joe", userId:2}
]
remove:[
{username:"Mike", userId:1}
]
Im stuck on constructing the logic inside the iteration. Maybe someone could give me a hint on this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…