数据源:
var jsonDate = [{
"面试日期": 43798,
"入社日期": 43800,
"工号": "532158",
"姓名": "张三",
"性别": "男",
"出生年月": "1994-01-17",
"身份证号码": "111111111111111111",
"推荐人": "富丽雅接待中心-刘志敏",
"备注": "无",
"离职时间": "在职",
"入住时间": 43802,
"退宿时间": 43802
}, {
"面试日期": 43798,
"入社日期": 43800,
"工号": "545132",
"姓名": "李四",
"性别": "男",
"出生年月": "1998-01-16",
"身份证号码": "222222222222222222",
"推荐人": "网络招聘A-张凯铭",
"备注": "无",
"离职时间": 43802,
"入住时间": 43802,
"退宿时间": 43802
}];
我的需求是通过js 把key转掉
JSON.parse(JSON.stringify(jsonDate).replace("面试日期", "ms_date")) 这种方式不行,
然后我定义一个新的key的数组
let a = ["ms_date", "rushe_date", "job_number", "name", "sex", "birthday", "idcard", "staff_id", "remarks", "leave_time", "ruzhu_time", "tuisu_time"];
let resultDate = jsonDate.map((item, index, arr) => {
console.log(index)
let obj = {};
for(let i in item){
obj[a[i]] = item[i];
console.log(obj)
}
return obj;
});
console.log(resultDate);
这里好像有点问题