From 5f5cb95b82d097dab715df70fb5e8106910995a4 Mon Sep 17 00:00:00 2001 From: Sny Date: Tue, 15 Mar 2022 13:08:06 +0530 Subject: [PATCH] OpenConceptLab/ocl_issues#1226 | CSV -> JSON | custom attributes datatype json --- ocldev/oclcsvtojsonconverter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ocldev/oclcsvtojsonconverter.py b/ocldev/oclcsvtojsonconverter.py index 75f74df..9d212a4 100755 --- a/ocldev/oclcsvtojsonconverter.py +++ b/ocldev/oclcsvtojsonconverter.py @@ -438,7 +438,8 @@ def get_auto_extra_attributes(self, csv_row, auto_attributes_def): re.escape(auto_attributes_def[self.DEF_KEY_AUTO_INDEX_PREFIX]), auto_attributes_def[self.DEF_KEY_AUTO_INDEX_REGEX], re.escape(auto_attributes_def[self.DEF_KEY_AUTO_INDEX_POSTFIX])) - data_types = ['bool', 'str', 'int', 'float', 'list'] + + data_types = ['bool', 'str', 'int', 'float', 'list', 'json'] # Process CSV columns for column_name in csv_row: @@ -727,6 +728,11 @@ def do_datatype_conversion(self, value, datatype): return float(value) elif datatype == 'list': return [v.strip() for v in value.strip('][').split(',')] + elif datatype == 'json': + try: + return json.loads(value) + except: + return value return value def process_auto_concept_reference(self, csv_row, field_def):