Reputation: 3
Good Day!
I'm new to NodeJs Express.js
how can i convert this data to nodejs, i need to calculate the data and display it on a table with loops? Any Tips for me guys?
here is the json data
{"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"}}
}
}
}
Upvotes: 0
Views: 740
Reputation: 8338
You can simple use JSON.parse:
for example if you want to access the employee_name field you can do something like :
obj = JSON.parse(json);
console.log(obj.employee_info.employee_name);
Upvotes: 2