fix(#95): replace regex JSON extraction with outermost-brace approach

_parse_action() used r'\{[^{}]*\}' regex which fails on nested
JSON (e.g. oracle text with braces). Now uses text.find/rfind to
extract the outermost { } block, handling nested structures.
Fixes issue #95 item 2.
This commit is contained in:
KoalaTrapLord authored and GitHub committed 2026-03-23 14:24:57 -04:00
1 parent 25e064d265
commit c1ad9e953c
1 file changed
+4 -3
+4 -3
View File
@@ -653,9 +653,10 @@ class DeepSeekBrain:
text = re.sub(r'\s*```$', '', text)
text = text.strip()
json_match = re.search(r'\{[^{}]*\}', text, re.DOTALL)
if json_match:
text = json_match.group(0)
start = text.find('{')
end = text.rfind('}')
if start != -1 and end != -1 and end > start:
text = text[start:end + 1]
try:
parsed = json.loads(text)