Need to improve method for cleaning nested object to remove empty objects as well
const sanitizeNestedObject = obj => JSON.parse(JSON.stringify(obj), (key, value) => {
if (value === null || value === "" || value === [] || value === {}) return undefined
return value
})
output after cleaning
{"expressions":[{
"hasSchemaTag":{"schemaTag":"Hardware"}},
{"hasAttribute":{"attribute":"serialNumber"}},{},{},
{"hasAnySchemaTags":{"schemaTags":["UCSFanModule","UCSMemoryArray"]}},{},{}
]}
expected output after cleaning
{"expressions":[{
"hasSchemaTag":{"schemaTag":"Hardware"}},
{"hasAttribute":{"attribute":"serialNumber"}},
{"hasAnySchemaTags":{"schemaTags":["UCSFanModule","UCSMemoryArray"]}}
]}