From
[
{
"id": "0001",
"name": "Jack",
"completeName": "Jack Smith"
},
{
"id": "0002",
"name": "Mary",
"completeName": "Mary Jackson"
},
{
"id": "0003",
"name": "John",
"completeName": "John Doe"
}
]
to this:
{
"Jack" :{
"id": "0001",
"name": "Jack",
"completeName": "Jack Smith"
},
"Mary" : {
"id": "0002",
"name": "Mary",
"completeName": "Mary Jackson"
},
"John": {
"id": "0003",
"name": "John",
"completeName": "John Doe"
}
}
reduce- create a new target object, walk all entries inreduceand add them on the fly to the target object withel.nameas keys. Done.