Fix grading parse.
This commit is contained in:
@@ -23,7 +23,7 @@ def process_response(input_string, quotation_check_field):
|
||||
index = input_string.index('{')
|
||||
# Extract everything after the first '{' (inclusive)
|
||||
result = input_string[index:]
|
||||
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result):
|
||||
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result, re.DOTALL | re.MULTILINE):
|
||||
parsed_string = result.replace("\"", "\\\"")
|
||||
pattern = r"(?<!\w)'|'(?!\w)"
|
||||
parsed_string = re.sub(pattern, '"', parsed_string)
|
||||
@@ -35,8 +35,8 @@ def process_response(input_string, quotation_check_field):
|
||||
else:
|
||||
json_obj = json.loads(result)
|
||||
return json_obj
|
||||
except json.JSONDecodeError:
|
||||
print("Invalid JSON string!")
|
||||
except Exception as e:
|
||||
print(f"Invalid JSON string! Exception: {e}")
|
||||
else:
|
||||
return input_string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user