Skip to content
Snippets Groups Projects
Commit 453e776c authored by Michelle Weidling's avatar Michelle Weidling :blowfish:
Browse files

feat: remove all empty fields

parent 45bb3f0f
No related branches found
No related tags found
No related merge requests found
Pipeline #509110 passed
......@@ -17,14 +17,14 @@ def remove_mongodb_id_from_result(json_data, result_type) -> list:
purged_list.append(d)
return purged_list
def remove_key_from_dict(d: dict, tbr_key: str) -> dict:
def remove_key_from_dict(d: dict) -> dict:
"""
This function removes keys with the value of null from the result.
"""
if isinstance(d, dict):
for key in list(d.keys()):
if key == tbr_key and d[key] == None:
if d[key] == None:
del d[key]
else:
remove_key_from_dict(d[key], tbr_key)
remove_key_from_dict(d[key])
return d
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment