Merged in hotfix/file-errors (pull request #448)
Hotfix/file errors * Set up test file * Fix regex pattern in json.loads * bug fix No valid JSON object found in the input string * bug fixes * moved try statement to parse fn * invalid literal for int() with base 10 error fixed * remove test * remove excess print statements * Raise error * Remove todo * Remove print statement Approved-by: Katon Minhas
This commit is contained in:
committed by
Katon Minhas
parent
31b2936ae6
commit
138ac82fa2
@@ -226,13 +226,15 @@ def primary_string_to_dict(string_dict, filename):
|
||||
|
||||
def universal_json_load(string_dict):
|
||||
"""Matches json dicts and list of dicts - NOT simple lists"""
|
||||
match = re.search(r'\{.*\}|\[\{.*\}\]', string_dict, re.DOTALL)
|
||||
match = re.search(r'\{.*\}|\[\s*?\{.*\}\s*?\]', string_dict, re.DOTALL) # Updated regex
|
||||
if match:
|
||||
try:
|
||||
return json.loads(match.group())
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
raise ValueError("No valid JSON object found in the input string")
|
||||
raise ValueError("No valid JSON object found in the input string")
|
||||
else:
|
||||
return {}
|
||||
|
||||
reimbursement_strings = [ # These are for `method='keyword'`
|
||||
"%",
|
||||
|
||||
Reference in New Issue
Block a user