From 80c27604bb5f7e4093abaca2663f215c62e86d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Clau=C3=9F?= Date: Wed, 24 May 2023 16:26:21 +0200 Subject: [PATCH] add list to transform objects --- src/paveit/helper/mongo.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/paveit/helper/mongo.py b/src/paveit/helper/mongo.py index 409ba4a..3e0f0a0 100755 --- a/src/paveit/helper/mongo.py +++ b/src/paveit/helper/mongo.py @@ -106,6 +106,12 @@ def mongo_to_dict(data, drop_parameters=['_cls','user_id', 'org_id', 'project_id del data[key] # Remove the unwanted key elif isinstance(data[key], dict): mongo_to_dict(data[key]) # Recurse into nested dictionaries + elif isinstance(data[key], list): # Add this line to process lists + for i, item in enumerate(data[key]): + if isinstance(item, ObjectId): + data[key][i] = str(item) + elif isinstance(item, dict): + mongo_to_dict(item, drop_parameters) # Recurse into nested dictionaries in list else: # process data if isinstance(data[key], ObjectId):