To remove empty rows from an object, require a generic solution.
The object has contain a list.
This is a sample object that i want to check
{
"test": {
"id": null
},
"testName": null,
"specimen": {
"id": null
},
"specimenName": null,
"collectionDate": null,
"resultDate": null,
"result": null,
"finding": null,
"resultValue": null
}
I had tried this, but it will not work when there is a list inside.
purgeEmptyRows(obj: any) : boolean {
let isEmpty = false;
Object.keys(obj).forEach(key => {
if (!obj[key]) {
isEmpty = false;
}else {
return true;
}
})
return isEmpty;
}