MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / read_json_file

Function read_json_file

src/core/utils.py:340–355  ·  view source on GitHub ↗

读取 JSON 文件 Args: filepath: 文件路径 Returns: JSON 数据,如果读取失败返回 None

(filepath: str)

Source from the content-addressed store, hash-verified

338
339
340def read_json_file(filepath: str) -> Optional[Dict[str, Any]]:
341 """
342 读取 JSON 文件
343
344 Args:
345 filepath: 文件路径
346
347 Returns:
348 JSON 数据,如果读取失败返回 None
349 """
350 try:
351 with open(filepath, 'r', encoding='utf-8') as f:
352 return json.load(f)
353 except (FileNotFoundError, json.JSONDecodeError, IOError) as e:
354 logging.getLogger(__name__).warning(f"读取 JSON 文件失败: {filepath} - {e}")
355 return None
356
357
358def write_json_file(filepath: str, data: Dict[str, Any], indent: int = 2) -> bool:

Callers

nothing calls this directly

Calls 1

warningMethod · 0.80

Tested by

no test coverage detected