当前位置:网站首页>处理数据 给数据换名字
处理数据 给数据换名字
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) 
边栏推荐
- “你“想当测试/开发程序员吗?努力发芽的我们......
- Realize OCR language recognition demo (II) - display and interaction of pictures and recognition content
- js 哪些情况不能用 JSON.parse 、JSON.stringify深拷贝及一个更好的深拷贝方法
- HCIP第十五天
- C#学习笔记----C#连接MySQL数据库
- 股票问题5连
- Cap principle of [distributed development]
- HRD 1. a simple and reliable HRD detection method
- Linux系统彻底删除Mysql
- Storage practices for high-performance computing scenarios, see here
猜你喜欢
随机推荐
My rich second generation friend
C语言·指针
Graph theory analysis of white matter brain function network: neural markers for classification and prediction of depression
周报、月报有多折磨人?万能报表模板建议收藏!(附模板)
Software testing interview question: where do your performance testing requirements come from?
Flink 在 讯飞 AI 营销业务的实时数据分析实践
2.2 comprehensive application questions - sequence table
BGP联邦实验
Matlab 44 animation gradient drawing programs
Load balancing SLB
Qlib教程——基于源码(二)本地数据保存与加载
GBase 8c 事务ID和快照(四)
Sort out SQL performance optimization and collect classics!
docker 本地搭建mysql主从
MATLAB 44种动漫渐变色绘图程序
GBase 8c 恢复控制函数
内容bypass分享
三舅的故事
Understand shader
股票问题5连









