0

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"}} } } }

2
  • 1
    "convert data to nodejs"? you mean parse the json as is using nodejs or convert it to array? Commented Dec 6, 2018 at 10:50
  • You cannot convert the data to nodejs. I believe what you are expecting is to parse this json data into a javascript object. You can do that with const obj = JSON.parse(data). Commented Dec 6, 2018 at 10:52

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.