Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions JsonPreprocessor/CJsonPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,18 @@ def __handleStrNoneTrueFalse(objJson):
else:
oJson[k] = v
return oJson

def __handleListElements(sInput : str) -> str:
items = re.split("\s*,\s*", sInput)
j=0
newItem = ""
for item in items:
j+=1
if j<len(items):
newItem = newItem + self.__checkAndUpdateKeyValue(item) + ","
else:
newItem = newItem + self.__checkAndUpdateKeyValue(item)
return newItem

jFile=jFile.strip()

Expand Down Expand Up @@ -699,15 +711,28 @@ def __handleStrNoneTrueFalse(objJson):
for item in items:
i+=1
newSubItem = ""
if re.search("\s*\[[^\[\]]*\]\s*,*\s*", item):
subItems = re.split("\s*,\s*", item)
j=0
for subItem in subItems:
j+=1
if j<len(subItems):
newSubItem = newSubItem + self.__checkAndUpdateKeyValue(subItem) + ","
else:
newSubItem = newSubItem + self.__checkAndUpdateKeyValue(subItem)
if re.search("^\s*\[.+\]\s*,*\s*$", item) and item.count('[')==item.count(']'):
item = item.strip()
bLastElement = True
if item.endswith(","):
bLastElement = False
item = re.sub("^\[", "", item)
item = re.sub("\s*\]\s*,*$", "", item)
newSubItem = __handleListElements(item)
newSubItem = "[" + newSubItem + "]" if bLastElement else "[" + newSubItem + "],"
elif re.search("^\s*\[.*\${.+", item):
item = item.strip()
item = re.sub("^\[", "", item)
newSubItem = __handleListElements(item)
newSubItem = "[" + newSubItem
elif re.search("]\s*,*\s*", item) and item.count('[') < item.count(']'):
item = item.rstrip()
bLastElement = True
if item.endswith(","):
bLastElement = False
item = re.sub("\s*\]\s*,*$", "", item)
newSubItem = __handleListElements(item)
newSubItem = newSubItem + "]" if bLastElement else newSubItem + "],"
else:
newSubItem = self.__checkAndUpdateKeyValue(item)
if i<len(items):
Expand Down