This is a return from an API call in JSON format. I know how to access the keys like "id", "name", "phone". But when it comes to accessing the array under "eldSettings", or the Objects keys under "tags", I'm having trouble. Currently I can loop though and console log "id", "name", "phone", and etc.
const driveArry = dataobj.data;
let tag = "";
for (let x in driveArry) {
tag += driveArry[x].name + "<br>";
}
console.log(tag);
JSON Return
"data":[
{
"id": "100",
"name": "Jon Wilson",
"username": "JWil",
"phone": "5555555555",
"eldSettings": {
"rulesets": [
{
"cycle": "USA 70 hour / 8 day",
"shift": "US Interstate Property",
"restart": "34-hour Restart",
"break": "Property (off-duty/sleeper)"
}
]
},
"timezone": "America/New_York",
"updatedAtTime": "2020-11-19T18:54:39.069917Z",
"createdAtTime": "2020-02-25T21:20:05.740835Z",
"carrierSettings": {
"carrierName": "",
"mainOfficeAddress": "",
"dotNumber": 0,
"homeTerminalName": "",
"homeTerminalAddress": ""
},
"driverActivationStatus": "active",
"tags": [
{
"id": "730",
"name": "Ocean Bay",
"parentTagId": "728"
},
{
"id": "1776",
"name": "Operations Unit",
"parentTagId": "14731"
},
{
"id": "2480",
"name": "Foremen",
"parentTagId": "1232"
},
{
"id": "137",
"name": "Ocean Bay Field Foreman 1",
"parentTagId": "1860"
},
{
"id": "1435",
"name": "Ocean Bay Pickups",
"parentTagId": "1223"
}
],
"staticAssignedVehicle": {
"id": "8081719",
"name": "1-22"
},
"vehicleGroupTag": {
"id": "1137",
"name": "Ocean Bay Field Foreman 1",
"parentTagId": "1230"
}
},