From a72269fd3f3a7bf0a0df4c3dce6664932d3cb9e5 Mon Sep 17 00:00:00 2001 From: eiglesias34 Date: Wed, 31 Jul 2024 18:04:20 +0200 Subject: [PATCH] Fixed issue with json lists --- rdfizer/rdfizer/functions.py | 42 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/rdfizer/rdfizer/functions.py b/rdfizer/rdfizer/functions.py index 19ae72f..0b46216 100644 --- a/rdfizer/rdfizer/functions.py +++ b/rdfizer/rdfizer/functions.py @@ -941,19 +941,22 @@ def string_substitution_json(string, pattern, row, term, ignore, iterator): if "[*]" in match: if match.split("[*]")[0] in row: child_list = row[match.split("[*]")[0]] - match = match.split(".")[1:] object_list = [] for child in child_list: - if len(match) > 1: - value = child[match[0]] - for element in match: - if element in value: - value = value[element] - else: - if match[0] in child: + if "." in match: + match = match.split(".")[1:] + if len(match) > 1: value = child[match[0]] + for element in match: + if element in value: + value = value[element] else: - value = None + if match[0] in child: + value = child[match[0]] + else: + value = None + else: + value = child if value is not None: if (type(value).__name__) != "str": if (type(value).__name__) != "float": @@ -1039,19 +1042,22 @@ def string_substitution_json(string, pattern, row, term, ignore, iterator): if match[:2] == "$.": match = match[2:] child_list = row[match.split("[*]")[0]] - match = match.split(".")[1:] object_list = [] for child in child_list: - if len(match) > 1: - value = child[match[0]] - for element in match: - if element in value: - value = value[element] - else: - if match[0] in child: + if "." in match + match = match.split(".")[1:] + if len(match) > 1: value = child[match[0]] + for element in match: + if element in value: + value = value[element] else: - value = None + if match[0] in child: + value = child[match[0]] + else: + value = None + else: + value = child if match is not None: if (type(value).__name__) == "int":