2 回答
TA贡献1874条经验 获得超12个赞
const gatewayB2c = [{
"singlemaxamt": "9999999999999",
"biztype": "1201",
"singleminamt": "0.01",
"bankcode": "000000",
"bankname": "招商银行",
"cdflag": "A"
}];
let data = [];
gatewayB2c.forEach(function (item) {
for (let [key, value] of Object.entries(item)) {
var obj = {
name: key,
value: value
};
data.push(obj);
}
});
console.log(data);
TA贡献1804条经验 获得超3个赞
let arr = [{
"singlemaxamt": "9999999999999",
"biztype": "1201",
"singleminamt": "0.01",
"bankcode": "000000",
"bankname": "招商银行",
"cdflag": "A"
}]
let newArr = [];
arr.forEach(item => {
for (var key in item) {
const obj = {
name: key,
value: item[key]
}
newArr.push(obj);
}
})
console.log(newArr);
添加回答
举报