Как удалить "1", 2, 3 и т.д. во всех вложенных объектах, при этом children, id, label должны остаться
[{
"1":{
"id":"get_link_offer",
"label":"get_link_offer",
"children":{
"1":{
"id":"get_link_offer",
"label":"get_link_offer"
}
}
},
"2":{
"id":"show_page_offers",
"label":"show_page_offers",
"children":{
"1":{
"id":"filters_offers",
"label":"filters_offers",
"children":{
"1":{
"id":"filter_offer_id",
"label":"filter_offer_id"
},
"2":{
"id":"filter_offer_category",
"label":"filter_offer_category"
},
"3":{
"id":"filter_offer_country",
"label":"filter_offer_country"
},
"4":{
"id":"filter_offer_type",
"label":"filter_offer_type"
},
"5":{
"id":"filter_offer_access",
"label":"filter_offer_access"
}
}
},
"2":{
"id":"show_offers",
"label":"show_offers",
"children":{
"1":{
"id":"available_objectives_offer",
"label":"available_objectives_offer"
},
"2":{
"id":"offer_category",
"label":"offer_category"
},
"3":{
"id":"offer_metrics",
"label":"offer_metrics"
},
"4":{
"id":"offer_countries",
"label":"offer_countries"
}
}
},
"3":{
"id":"show_offer_details",
"label":"show_offer_details",
"children":{
"1":{
"id":"button_get_access_to_offer",
"label":"button_get_access_to_offer"
},
"2":{
"id":"show_available_sources_in_offer",
"label":"show_available_sources_in_offer"
},
"3":{
"id":"show_prohibited_sources_in_offer",
"label":"show_prohibited_sources_in_offer"
},
"4":{
"id":"show_available_countries_in_offer",
"label":"show_available_countries_in_offer"
},
"5":{
"id":"show_metrics_table",
"label":"show_metrics_table"
},
"6":{
"id":"show_target_table",
"label":"show_target_table"
}
}
}
}
},
"3":{
"id":"show_all_tools",
"label":"show_all_tools",
"children":{
"1":{
"id":"show_page_streams",
"label":"show_page_streams",
"children":{
"1":{
"id":"filters_streams",
"label":"filters_streams",
"children":{
"1":{
"id":"period_created_stream",
"label":"period_created_stream"
}
}
},
"2":{
"id":"table_streams",
"label":"table_streams",
"children":[
...
]
}
}
}
}
}
}]
Object.values(response).map(function (key, index) {
let data = []
data.id = key.id;
data.label = key.label;
if (key.children) {
this.children(key.children)
}
console.log(data)
}.bind(this));
children(children) {
Object.values(children).map(function (key, index) {
console.log(key)
if (key.children) {
return key.children
} else {
return key
}
});
},