【发布时间】:2021-02-17 21:20:06
【问题描述】:
我正在尝试转换这个 json 数组
[
{empnum:"10",fullname:"john doe",dateofhire:"2000-01-01:12:00:00", lastupdate:"2021-02-02"},
{empnum:"20",fullname:"john smith",dateofhire:"1990-02-01:12:00:00", lastupdate:"2021-01-02"},
{empnum:"30",fullname:"john wayne",dateofhire:"2005-01-03:12:00:00", lastupdate:"2021-02-01"},
]
进入这2个字符串数组
["empnum","fullname","dateofhire","lastupdate"]
[
["10","john doe","2000-01-01:12:00:00","2021-02-02"],
["20","john smith","1990-02-01:12:00:00","2021-01-02"],
["30","john wayne","2005-01-03:12:00:00","2021-02-01"],
]
一个包含 json 属性,另一个包含值
我在使用 map 和 Object.entries 时遇到了困难,但总是出错
结果是json数组
const x = result.map((rec)=>{
var keys = rec.map((e)=>{
return(e.keys)
})
var values = keys.join(",").split(",")
return values
})
任何提示我怎么能得到这个? 谢谢
【问题讨论】: