Could you please tell me How to remove the object with all null values in json using javascript.
I need to remove the nested objects with null/empty keys too.
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"text": null,
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"definition": null
},
"GlossSee": "markup",
"window": {
"title": "Sample Konfabulator Widget",
"description": ""
}
}
}
},
"image": {
"src": null,
"name": null,
"alignment": null
},
"text": {
"data": "Click Here",
"size": null,
"style": "bold",
"name": "text1",
"hOffset": "",
"vOffset": "",
"alignment": "center",
"onMouseUp": null
}
}
}
Need the output as follows:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook."
},
"GlossSee": "markup",
"window": {
"title": "Sample Konfabulator Widget"
}
}
}
},
"text": {
"data": "Click Here",
"style": "bold",
"name": "text1",
"alignment": "center"
}
}
}
How to remove the object with null or empty keys in the whole json even recursively.
Like the image
object which has keys with empty or null values.