var jsonArray = [];
var zzarray = ['a','b']; // json key
var daarray = [1,2]; // json value
for(var i = 0;i<zzarray.length;i++){
var json = {};
for(var j=0;j<daarray.length;j++){
if(i==j){
json.value = daarray[j];
json.name = zzarray[i];
jsonArray.push(json);
}
}
}
console.log(jsonArray)
轉(zhuǎn)https://blog.csdn.net/rjkkaikai/article/details/80596638