我有這樣的對象數組:找到鑰匙,並創建新的對象
[{
"f_name":"nand",
"lastName":"bhatt",
"gender":"",
"email":"[email protected]",
"mobileNo":"0043 664 321 54 76",
"company":"IBM Bhimtal"
}, {
"f_name":"Pooran",
"lastName":"Pradhan",
"gender":"male",
"email":"[email protected]",
"mobileNo":"13123123123",
"company":"Google"
}, {
"f_name":"Krishna",
"lastName":"Bhatt",
"gender":"Male",
"email":"[email protected]", "mobileNo":"983232324",
"company":"IBM"
}];
我想類似這樣的一個新的對象:
[
{
field_name:f_name, sample: ['nand','Pooran','Krishna'],
field_name:lastName, sample: ['bhatt','Pradhan','Bhatt'],
field_name:gender, sample: ['','male','Male'],
field_name:email, sample: ['[email protected]','[email protected]','[email protected]'],
field_name:mobileNo, sample: ['0043 664 321 54 76','13123123123','983232324'],
}]
任何想法,我們應該怎麼在lodash做到這一點?
簡單的_.map解決了我的問題。 – 2015-04-03 00:22:10