|
@@ -57,12 +57,11 @@ def safe_json_parse(json_str: str, default: Any = None) -> Any:
|
|
|
# 预处理空字符串
|
|
|
stripped_str = json_str.strip()
|
|
|
if not stripped_str:
|
|
|
- return default if default is not None else []
|
|
|
-
|
|
|
+ raise ValueError("Empty JSON string")
|
|
|
try:
|
|
|
data = json.loads(stripped_str)
|
|
|
- except json.JSONDecodeError:
|
|
|
- return default if default is not None else []
|
|
|
+ except json.JSONDecodeError as e:
|
|
|
+ raise ValueError(f"Invalid JSON: {e}")
|
|
|
|
|
|
# 递归检查嵌套空列表
|
|
|
def is_empty_nested_list(obj):
|
|
@@ -540,11 +539,11 @@ class File(models.Model):
|
|
|
break
|
|
|
node['meta'] = metaJson
|
|
|
except Exception as error:
|
|
|
- logger.info(f"尝试以json格式解析文件meta内容{line[el]}失败,尝试以非标准格式解析{error}")
|
|
|
+ # logger.info(f"尝试以json格式解析文件meta内容{line[el]}失败,尝试以非标准格式解析{error}")
|
|
|
# 尝试以冒号分隔格式解析
|
|
|
- elList = el.split(':')
|
|
|
+ elList = line[el].strip().split(':', 1)
|
|
|
if len(elList) != 2:
|
|
|
- logger.info(f"尝试以非标准格式解析文件meta内容{el}失败,放弃解析")
|
|
|
+ # logger.info(f"尝试以非标准格式解析文件meta内容{el}失败,放弃解析")
|
|
|
continue
|
|
|
else:
|
|
|
node['meta'].append({
|