Here is a sample json for reference:
{
"search": {
"facets": {
"author": [
],
"language": [
{
"value": "nep",
"count": 3
},
{
"value": "urd",
"count": 1
}
],
"source": [
{
"value": "West Bengal State Council of Vocational Education & Training",
"count": 175
}
],
"type": [
{
"value": "text",
"count": 175
}
],
}
}
There are multiple ways to remove the key search.facets.source
:
delete search.facets.source
delete jsobObj['search']['facets']['source']
var jsonKey = 'source'; JSON.parse(angular.toJson(jsonObj), function (key, value) { if (key != jsonKey) return value; });
Options 1 and 2 are static, while option 3 is a potential solution but may not work effectively if the 'source' key is nested elsewhere in the JSON. Can anyone suggest a dynamic method to delete the key in any nested structure, as it is not feasible to predict the array sequence dynamically as in options 1 and 2?