1 回答
TA贡献1779条经验 获得超6个赞
您需要从livedata. 你可以使用每个键-值对Object.entries和reduce数组到你想要的对象:
const livedata = [{
"earningsFileId": {
"value": 1234
},
"paymentType": {
"value": "Session",
"errors": [{
"id": 802462,
"message": "Invalid Combination",
"status": "Processing"
}]
},
"detailStatus": {
"value": "Processing"
}
},
{
"earningsFileId": {
"value": 5678
},
"paymentType": {
"value": "Session",
"errors": [{
"id": 802462,
"message": "Invalid Combination",
"status": "Processing"
}]
},
"detailStatus": {
"value": "Processing"
}
}
];
const result = livedata.map(d =>
Object.entries(d).reduce((acc, [k, v]) => {
acc[k] = v.value;
return acc;
}, {}))
console.log(result);
添加回答
举报