I have this JSON object myFilters:
{"filters":
{"role":"","jobs":[]}
}
I can correctly remove the empty object from it with this function clean (myFilters):
function clean(obj) {
for (var propName in obj) {
if (
obj[propName] === null ||
obj[propName] === undefined ||
obj[propName] === ""
) {
delete obj[propName];
}
}
So now, my myFilters object becomes:
{"filters":
{ "jobs":[] }
}
How can I now remove the empty array and the key from my JSON object?