求大佬指点哈!怎么用原始数据,组出这个结构

{
"info":[
{"Id":1,"new":true,"name":"james","goods":"iphone"},
{"Id":3,"new":true,"name":"Chen","goods":"SM"}
],
"combo":[
{"comboPlay":"oneByTwo","count":10},
{"comboPlay":"special","count":15},
{"comboPlay":"specialTwo","count":1}
],
"comboRef":[
{"combo":"yes","payOut":310.25,"type":2},
{"combo":"yes","payOut":200.35,"type":2},
{"combo":"yes","payOut":250.10,"type":1}
]
}
要用上面的数据组出下面的结构
{
"info":[
{"Id":1,"name":"james","goods":"iphone"},
{"Id":3,"name":"Chen","goods":"SM"}
],
"combo":[
{"comboPlay":"oneByTwo","count":10,"payOut":310.25,"type":2},
{"comboPlay":"special","count":15,"payOut":200.35,"type":2},
{"comboPlay":"specialTwo","count":1,"payOut":200.35,"type":1}
]
}
组完的info的内容都来自于原始数据的info
而组完的combo的内容是由原始数据的combo和comboRef组出的这比较麻烦
有没有什么好方法可以组出这个数据?
一只萌萌小番薯
浏览 319回答 2
2回答

qq_遁去的一_1

letgo={"info":[{"Id":1,"new":true,"name":"james","goods":"iphone"},{"Id":3,"new":true,"name":"Chen","goods":"SM"}],"combo":[{"comboPlay":"oneByTwo","count":10},{"comboPlay":"special","count":15},{"comboPlay":"specialTwo","count":1}],"comboRef":[{"combo":"yes","payOut":310.25,"type":2},{"combo":"yes","payOut":200.35,"type":2},{"combo":"yes","payOut":250.10,"type":1}]}functioncombination(data){varcomparison=data.comboRef;data.combo.map((v,i)=>{Object.assign(v,comparison[i])})deletedata.comboRefreturndata}console.log(combination(go))
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript