如何循环嵌套的JSON数据?我需要知道编码它的正确方法 . 我在这里有一些未完成的代码,我只是不明白如何循环来自JSON文件的节点js .

EJS模板

<% for (x in schedData) { %>
<label>Employee ID:</label>
<p><%- x %></p><br>
<% } %>

<label>Employee Name:</label>
<% for (n in schedData[x]) {%>
<p><%- schedData[x][n].employee_name %></p><br>
    <% } %>
<table style="Border: 1px solid black">
    <tr>

        <th>Date</th>
        <th>Time In</th>
        <th>Time Out</th>
        <th>Schedule Shift In</th>
        <th>Schedule Shift Out</th>
        <th>Total Hours</th>
        <th>Considered Hours</th>
        <th>Break Duration (Hrs)</th>
        <th>Break Instance</th>
        <th>Late (Mins)</th>
        <th>Undertime (Mins)</th>
        <th>Reg OT (Hrs)</th>
    </tr>
    <tr>

            <% for (y in schedData) {%>
        <td><%- Object.keys(schedData[y].date_log) %></td>
        <% } %>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>

    </tr>

</table>

我不确定我是否正确输入它 .

JSON文件

{"652":
    {"employee_info":
            {"employee_name":"Byron Mataya"},
        "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"
                            }}
                    }
                }

}

从json文件中获取所有数据非常困惑 .

Here is my output showing some details coming off from json file, using express js