Files
aistory-generate/test_json.py
T
Mai-Vu Tran 6699c516cd first commit
2026-03-16 18:14:44 +07:00

24 lines
408 B
Python

import re
import json
content = """Sure, here are some suggestions:
```json
{
"suggestions": [
{"title": "A", "description": "B"}
]
}
```
Good luck!
"""
match = re.search(r'(\{[\s\S]*"suggestions"[\s\S]*\})', content)
if match:
try:
data = json.loads(match.group(1))
print("SUCCESS:", data)
except Exception as e:
print("FAIL LOAD:", e)
else:
print("NO MATCH")