【发布时间】:2018-12-06 18:53:05
【问题描述】:
美好的一天!
我是 NodeJs Express.js 的新手
如何将此数据转换为 nodejs,我需要计算数据并将其显示在带有循环的表上?大家有什么建议吗?
这是json数据
{"652":
{"employee_info":
{"employee_name":""},
"date_log":
{
"2017-12-31":
{
"config":{"shift":"R","hours_per_day":8,"break_hours":1,"flexi_hours":0,"grace_period":15},
"log":{"time_in":"2017-12-31 07:35:37","time_out":"2017-12-31 09:34:01","break_out":["2017-12-31 12:00:00"],"break_in":["2017-12-31 13:00:00"],"shift_in":"2017-12-31 16:00:00","shift_out":"2017-12-31 16:00:00","status":"present","holiday":"no","overtime":"no"}
},
"2017-12-29":
{
"config":{"shift":"FL","hours_per_day":8,"break_hours":1,"flexi_hours":2,"grace_period":0},
"log":{"time_in":"2017-12-29 00:20:00","time_out":"2017-12-29 10:35:00","break_out":["2017-12-31 12:00:00"],"break_in":["2017-12-31 13:00:00"],"shift_in":"2017-12-29 16:00:00","shift_out":"2017-12-29 16:00:00","status":"present","holiday":"no","overtime":"no"
}
},
"2017-12-28":
{
"config":{"shift":"R","hours_per_day":8,"break_hours":1,"flexi_hours":0,"grace_period":0},
"log":{"time_in":"2017-12-28 00:02:25","time_out":"2017-12-29 10:35:00","break_out":["2017-12-31 12:00:00"],"break_in":["2017-12-31 13:00:00"],"shift_in":"2017-12-28 16:00:00","shift_out":"2017-12-28 16:00:00","status":"present","holiday":"no","overtime":"no"}}
}
}
}
【问题讨论】:
-
“将数据转换为 nodejs”?您的意思是使用 nodejs 解析 json 或将其转换为数组?
-
您无法将数据转换为nodejs。我相信您所期望的是将此 json 数据解析为 javascript 对象。你可以用
const obj = JSON.parse(data)来做到这一点。
标签: arrays node.js json express