I am completely new to Typescript and have been able to make some progress in other areas but am struggling with creating interfaces for the deeply nested objects with "taskName" and "totalTaskHours". The data looks like this:
[
{
"20229622": [
{
"taskName": "Project Management",
"totalTaskHours": "1589.4"
},
{
"taskName": "Marketing",
"totalTaskHours": "1306.8"
},
{
"taskName": "Design",
"totalTaskHours": "212.4"
},
{
"taskName": "Programming",
"totalTaskHours": "415.8"
}
]
},
{
"20229623": [
{
"taskName": "Project Management",
"totalTaskHours": "980.1"
},
{
"taskName": "Marketing",
"totalTaskHours": "717.3"
},
{
"taskName": "Design",
"totalTaskHours": "468.9"
}
]
},
{
"20229624": [
{
"taskName": "Programming",
"totalTaskHours": "5930.1"
},
{
"taskName": "Project Management",
"totalTaskHours": "997.2"
},
{
"taskName": "Marketing",
"totalTaskHours": "2108.69"
},
{
"taskName": "Design",
"totalTaskHours": "529.2"
}
]
}
]
I have tried to get down to the objects inside the nested array but I am getting errors each time.
I have tried with the following (obviously wrong):
interface TaskItem {
taskName: string;
totalTaskHours: string;
}
interface TaskItemArray {
[key:string]: {
[key:string]: TaskItem[];
};
}
interface TaskBreakdownSummedByCategory {
[key:string]: TaskItemArray[];
}
I have also tried the following but the data is too shallow:
interface TaskItem {
taskName: string;
totalTaskHours: string;
}
interface TaskBreakdownSummedByCategory {
[key:string]: TaskItem;
}
Can someone help me out really quick with this issue? I am still learning but the basic tutorials dont really go through deep nested objects. Thanks!