为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

一只萌萌小番薯 2019-08-17 11:08:42
{"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组出的这比较麻烦有没有什么好方法可以组出这个数据?
查看完整描述

2 回答

?
qq_遁去的一_1

TA贡献1725条经验 获得超7个赞

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.comboRef
returndata
}
console.log(combination(go))
                            
查看完整回答
反对 回复 2019-08-17
  • 2 回答
  • 0 关注
  • 318 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信