Need a universal solution to eliminate empty rows from an object.
The object contains a list of properties.
Here is a sample object that needs checking:
{
"test": {
"id": null
},
"testName": null,
"specimen": {
"id": null
},
"specimenName": null,
"collectionDate": null,
"resultDate": null,
"result": null,
"finding": null,
"resultValue": null
}
Previous attempts failed, especially when there are lists inside the object.
purgeEmptyRows(obj: any): boolean {
let isEmpty = false;
Object.keys(obj).forEach(key => {
if (!obj[key]) {
isEmpty = false;
} else {
return true;
}
})
return isEmpty;
}