fix: fix a small bug in json_mode (#1041)

This commit is contained in:
amstrongzyf
2025-07-09 14:33:24 +08:00
committed by GitHub
parent 5c7030964b
commit 7c41fce8b9
+1 -3
View File
@@ -109,14 +109,12 @@ class JSONParser:
out.append(tokval)
result = "".join(out)
# Validate if the result is valid JSON
json.loads(result)
return result
except (tokenize.TokenError, json.JSONDecodeError):
# If tokenize fails, fallback to regex method
for python_val, json_val in replacements.items():
json_str = re.sub(rf"\\b{python_val}\\b", json_val, json_str)
json_str = re.sub(rf"\b{python_val}\b", json_val, json_str)
return json_str
@staticmethod