I am working on a project where I am fetching employee attendance data from an API, and the response is structured as follows:
{
“result”: [
{
“attendanceDetails”: {
“2024-08-26”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Janmashtami(Holiday)”,
“FirstIn_Building”: “-”,
“OverTime”: “00:00”,
“LastOut_Location”: “-”,
“ShiftName”: “General”,
“FirstIn”: “-”,
“FirstIn_Location”: “-”,
“TotalHours”: “00:00”,
“WorkingHours”: “08:00”,
“LastOut_Building”: “-”,
“LastOut”: “-”,
“ShiftEndTime”: “12:00 AM”
},
“2024-08-27”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Absent”,
“FirstIn_Building”: “-”,
“LastOut_Location”: “-”,
“ShiftName”: “General”,
“FirstIn”: “-”,
“FirstIn_Location”: “-”,
“TotalHours”: “00:00”,
“WorkingHours”: “00:00”,
“LastOut_Building”: “-”,
“LastOut”: “-”,
“DeviationTime”: “08:00”,
“ShiftEndTime”: “12:00 AM”
}
},
“employeeDetails”: {
“mail id”: “example@example.com”,
“erecno”: “131572000000234001”,
“last name”: “Doe”,
“first name”: “John”,
“id”: “AI001”
}
}
]
}
I need to convert this response into the following format:
{
“attendanceRecords”: [
{
“date”: “2024-08-26”,
“employeeId”: “AI001”,
“firstName”: “John”,
“lastName”: “Doe”,
“email”: “example@example.com”,
“shiftStartTime”: “12:00 AM”,
“status”: “Janmashtami(Holiday)”,
“firstInBuilding”: “-”,
“overTime”: “00:00”,
“lastOutLocation”: “-”,
“shiftName”: “General”,
“firstIn”: “-”,
“firstInLocation”: “-”,
“totalHours”: “00:00”,
“workingHours”: “08:00”,
“lastOutBuilding”: “-”,
“lastOut”: “-”,
“shiftEndTime”: “12:00 AM”
}
]
}
The reason for the conversion is that in the original format, I cannot iterate properly for processing in my Bubble.io application. Can anyone guide me on how to achieve this? Thank you!