怎样把下边的数组,这个gatewayB2c是动态的,例如这种:
"gatewayB2c": [{
"singlemaxamt": "9999999999999",
"biztype": "1201",
"singleminamt": "0.01",
"bankcode": "000000",
"bankname": "招商银行",
"cdflag": "A"
}]
转化成下面这种格式呢?
[{name: "singlemaxamt", value: "9999999999999"},
{name: "biztype", value: "1201"},
{name: "singleminamt", value: "0.01"},
{name: "bankcode", value: "000000"},
{name: "bankname", value: "招商银行"},
{name: "cdflag", value: "A"}]
已经把gateWayB2c的值取出来了,是这么写的
var ccc=gatewayB2c;
ccc.forEach(function(v,i){
var bbb = Object.keys(v);
Object.keys(v).forEach(function(v){
/*console.log(v)//取到了key
console.log(ccc[i][v])//取到了值*/
var name = v;
var value = ccc[i][v];
var c=bbb.length;
//arr.push("name:"+v,"value:"+ccc[i][v]);
console.log(name+'------'+value);
})
console.log(arr);
})
值是这样
singlemaxamt------9999999999999
biztype------1201
singleminamt------0.01
bankcode------000000
bankname------招商银行
cdflag------A
下边就不知道该怎么写了
HUWWW
狐的传说
相关分类