In the python3 code below I read all the objects in the json then loop through the elements in the json. If I only search for the id is not None that element and the null value are removed. However when I add the or statement to remove the id is not "" the entire file is printed with neither of the id in the or statement removed. Being new to python I am not sure what I am doing wrong. Thank you :).
file
{
"objects": [
{
"version": "1",
"list": [
{
"
"json": null
},
"id": "",
}
],
"h": "na"
},
{
"version": "1",
"list": [
{
"
"json": null
},
"id": "This has text in it and should be printed",
}
],
"h": "na"
},
{
"version": "1",
"list": [
{
"
"json": null
},
"id": null,
}
],
"h": "na"
}
]
}
desired
{
"version": "1",
"list": [
{
"
"json": null
},
"id": "This has text in it and should be printed",
}
],
"h": "na"
},
python3
if v["id"] is not None or v['id'] is not "":
Also tried the below and id were changed:
for obj in data['objects']:
if obj.get('id') is "":
obj['description'] = 'na'