当前位置:网站首页>处理数据 给数据换名字
处理数据 给数据换名字
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) 
边栏推荐
猜你喜欢

Leetcode 2347. the best poker hand

N32L43x Flash读\写\擦除操作总结

Baidu PaddlePaddle easydl: when AI enters the factory, "small bearing" can also turn "big industry"

VLAN实验

leetcode: 515. 在每个树行中找最大值

Graph theory analysis of white matter brain function network: neural markers for classification and prediction of depression

Storage practices for high-performance computing scenarios, see here

抓包精灵NetCapture APP抓包教程《齐全》

路由策略简介

Lambda表达式和Stream流
随机推荐
Interview question 01.08. Zero matrix
2.2 comprehensive application questions - sequence table
GBase 8c 备份控制函数(四)
一些事情的思考
牛客多校第三场A,C+权值线段树
GBase 8c 事务ID和快照(五)
For newly installed PIP3, use no module named 'LSB_ Release 'problem
企业运维实践-使用Aliyun容器镜像服务对海外gcr、quay仓库镜像进行镜像拉取构建
C # learning notes ----- C # connect to MySQL database
硬件SPI与软件模拟SPI速率对比
HCIP第十三天笔记
Oracle RAC cluster file directory migration
VPP之DPDK插件
GBase 8c 事务ID和快照(六)
Recursion related exercises
GBase 8c 备份控制函数(三)
Dart 代码注释和文档编写规范
String
C language · pointer
Realize OCR language recognition demo (II) - display and interaction of pictures and recognition content