data = [
{
"2022": [
{
"Title": "Title"
},
{
"Title": "Title 2"
}
]
},
{
"2023": []
},
{
"2024": []
}
]
Now I want to remove 2023 and 2024 because it do not have any value. Solution in python :
for el in data:
for dict in el.values():
if len(dict) == 0:
data.remove(el)
Similar Solution in JS :
data = data.filter(item=>Object.values(item)[0].length > 0)
What i want is similar to js. (I am not an expert in python)
data = [item for item in data if next(iter(item.values()))]data. Will they ever contain anything else than a single year key?list.append()to connate multiple json file. there are more process goes on till we reach this point. here JSON object are not manual driven.