Skip to content

Commit

Permalink
Updated dynamic paths for imported JSON files feature
Browse files Browse the repository at this point in the history
  • Loading branch information
namsonx committed Oct 31, 2024
1 parent 9ac0349 commit 87fc582
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions JsonPreprocessor/CJsonPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,18 +1476,23 @@ def __preCheckJsonFile(self, sInput, CJSONDecoder):
f"{error}\nNearby: '{failedJsonDoc}'"
self.__reset()
raise Exception(jsonException)
importPattern = r'([\'|"]\s*\[\s*import\s*\]\s*[\'|"]\s*:\s*[\'|"][^\'"]+[\'|"])'
sJson = ''
while re.search(r"'\s*\[\s*import\s*\]\s*'", str(self.jsonCheck)):
self.__checkDotInParamName(self.jsonCheck)
oJson, bNested = self.__updateAndReplaceNestedParam(self.jsonCheck)
sJson = json.dumps(oJson)
checkDynamicImport = re.search(r'("\s*\[\s*import\s*\]\s*"\s*:\s*"[^"]+")', sJson)
if checkDynamicImport is None or '${' in checkDynamicImport[0]:
raise Exception('TBD')
while self.bDynamicImport:
if sJson=='':
sJson = str(self.jsonCheck)
lImport = re.findall(importPattern, sJson)
if len(lImport)==0:
self.bDynamicImport = False
else:
sJson = re.sub(r'"\s*\[\s*import\s*\]\s*":\s*"[${]+[^"]+"', checkDynamicImport[0], sJson)
self.__preCheckJsonFile(sJson, CJSONDecoder)
self.bDynamicImport = False
self.__checkDotInParamName(self.jsonCheck)
oJson, bNested = self.__updateAndReplaceNestedParam(self.jsonCheck)
sJson = json.dumps(oJson)
lImport = re.findall(importPattern, sJson)
if any('${' in item for item in lImport):
self.__preCheckJsonFile(sJson, CJSONDecoder)
else:
self.bDynamicImport = False
return sJson if sJson!='' else sInput

def jsonLoad(self, jFile : str):
Expand Down

0 comments on commit 87fc582

Please sign in to comment.