我一直在尝试合并数据并获得以下结果:
data = [{serviceID: 22, quantite: 120, typeConviveId: 6},
{serviceID: 23, quantite: 240, typeConviveId: 6},
{serviceID: 24, quantite: 100, typeConviveId: 7},
{serviceID: 25, quantite: 150, typeConviveId: 7}]
最后需要什么:
result: [ { "22": "120", "23": "240", "typeConviveId": "6"},
{ "24": "100", "25": "150", "typeConviveId": "7" } ]
答案 0 :(得分:0)
您可以使用Array.prototype.map
,Array.prototype.filter
和Array.prototype.reduce
的组合,以及使用typeConviveId
和{{1 }}:
Set