当前位置:网站首页>处理数据 给数据换名字
处理数据 给数据换名字
2022-07-27 23:56:00 【MMNHD】

a:[
{"手机号":1321312123,'姓名':'啊牛'},
{"手机号":888888,'姓名':'王五'},
],
b:{
'姓名':'user',
'手机号':'mobile'
}
要的格式 [
{user:'啊牛'},
{mobile:1321312123}
]
export function getImportJsData(results, header) {
const newArr = []
// 将所有的中文key转换成英文key 然后添加到新数组中
results.forEach(item => {
const map = {}
Object.keys(item).forEach(key => {
map[header[key]] = item[key]
})
newArr.push(map)
})
// 时间处理
newArr.forEach(item => {
Object.keys(item).forEach(key => {
if (key === 'timeOfEntry') {
item[key] = new Date(formatDate(item[key], '/'))
}
})
})
return newArr
}
getImportJsData(a,b) 
边栏推荐
猜你喜欢
随机推荐
面试题 01.09. 字符串轮转
GBase 8c 事务ID和快照
QT setting Icon
Interview question 01.05. Primary editing
[style set 1] tab
Login function implementation
小散量化炒股记|量化系统中数据是源头,教你搭建一款普适的数据源框架
JG data reset (WD)
For newly installed PIP3, use no module named 'LSB_ Release 'problem
qt 设置图标
Interview question 01.06. string compression
【向 Dice Roller 应用添加图片】
C语言·指针
【分布式开发】之 CAP 原则
Software test interview question: think_ What is the function of time?
How to calculate the profit and loss of spot Silver
【taichi】在太极中画出规整的网格
Article reproduction: super resolution network fsrcnn
面试官:你确定Redis是单线程的进程吗?
阿门的故事








