From 16c756259ad20908525076b7d4d2f4fe85ae0541 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Thu, 12 Mar 2026 15:43:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(json=5Futils):=20=E8=A7=A3=E5=86=B3=20?= =?UTF-8?q?=E2=80=9Cfixed=5Fjson=5Ftext=E2=80=9D=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=9C=AA=E7=BB=91=E5=AE=9A=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/infrastructure/analysis/utils/json_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/infrastructure/analysis/utils/json_utils.py b/src/infrastructure/analysis/utils/json_utils.py index f9c2a1f..ecf8975 100644 --- a/src/infrastructure/analysis/utils/json_utils.py +++ b/src/infrastructure/analysis/utils/json_utils.py @@ -94,6 +94,7 @@ def parse_json_response( Returns: (成功标志, 解析后的数据列表, 错误消息) """ + fixed_json_text = None try: # 1. 提取JSON部分 json_match = re.search(r"\[.*?\]", result_text, re.DOTALL) @@ -125,9 +126,7 @@ def parse_json_response( except json.JSONDecodeError as e: error_msg = f"{data_type}JSON解析失败: {e}" logger.warning(error_msg) - logger.debug( - f"修复后的JSON: {fixed_json_text if 'fixed_json_text' in locals() else 'N/A'}" - ) + logger.debug(f"修复后的JSON: {fixed_json_text or 'N/A'}") return False, None, error_msg except Exception as e: error_msg = f"{data_type}解析异常: {e}"