I need to display nested JSON Object coming from my backend as the column fields of my MatTableDataSource.
This is my JSON Object:
[{
"workstationId": 100,
"assemblylineId": 100,
"workstationDescription": "Testing1",
"workstationTest": "Yes",
"createdAt": "2019-03-20",
"updatedAt": "2019-03-20",
"assemblylines": [{
"assemblylineName": "assembly1"
}]
},
{
"workstationId": 101,
"assemblylineId": 100,
"workstationDescription": "workstation1",
"workstationTest": "No",
"createdAt": "2019-04-04",
"updatedAt": "2019-04-04",
"assemblylines": [{
"assemblylineName": "assembly5"
}]
},
{
"workstationId": 102,
"assemblylineId": 101,
"workstationDescription": "workstation2",
"workstationTest": "No",
"createdAt": "2019-04-04",
"updatedAt": "2019-04-04",
"assemblylines": [{
"assemblylineName": "assembly4"
}]
},
{
"workstationId": 103,
"assemblylineId": 102,
"workstationDescription": "Testing2",
"workstationTest": "Yes",
"createdAt": "2019-04-04",
"updatedAt": "2019-04-04",
"assemblylines": [{
"assemblylineName": "assembly3"
}]
}
]
This is my UI: MatTableDataSource
This is my workstation.model.ts
export interface Workstation {
workstationId: number;
workstationDescription: string;
workstationTest: string;
assemblylines: {
assemblylineName: string;
};
}
I have checked tutorials of JSON Object Destructuring, Parsing, Stringifying but I'm not getting there as the service is returning Workstation[] object instead of Workstation object. Kindly let me know if there's a way I can display assemblylineName property as a column with its values.