I need help understanding how to properly create a model class for the data I am using. I know what to do when it is just one array of objects which would be something like:
export class Education {
complete: boolean;
course: string;
}
for the json data:
{
"educationData": [
{
"codeschool": [
{
"complete": "true",
"course":"Front end foundations"
},
{
"complete": "false",
"course": "Front end formations"
}
]
}
But suppose I am taking classes from another school and I have the following json data. I now have two arrays of objects within my educationData :
{
"educationData": [
{
"codeschool": [
{
"complete": "true",
"course":"Front end foundations"
},
{
"complete": "false",
"course": "Front end formations"
}
],
"egghead": [
{
"complete": "true",
"course": "Getting started with angular"
},
{
"complete": "true",
"course": "Learn HTTP in angular"
}
]
}
]
}
Would I just leave the class model the same as
export class Education {
complete: boolean;
course: string;
}
Or do I now need to declare both the codeschool and egghead arrays? If this is the correct way to do it, then I know my syntax is completely wrong because I haven't been able to find much info on this type of case:
export class Education {
codeschool: Array<Objects>;
{
complete: boolean;
course: string;
},
egghead: Array<Objects>;
{
complete: boolean;
course: string;
}
}