mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 07:57:44 +00:00
fix: fix a small bug in json_mode (#1041)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user