MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _read_json_file

Function _read_json_file

graphify/diagnostics.py:271–286  ·  view source on GitHub ↗

Read a JSON graph after applying Graphify's graph-load size cap.

(path: str | Path)

Source from the content-addressed store, hash-verified

269
270
271def _read_json_file(path: str | Path) -> dict[str, Any]:
272 """Read a JSON graph after applying Graphify's graph-load size cap."""
273 from graphify.security import check_graph_file_size_cap
274
275 json_path = Path(path)
276 check_graph_file_size_cap(json_path)
277 try:
278 data = json.loads(json_path.read_text(encoding="utf-8"))
279 except (json.JSONDecodeError, OSError) as exc:
280 raise RuntimeError(
281 f"Cannot parse {json_path}: {exc}. "
282 "The file may be corrupted — re-run 'graphify extract'."
283 ) from exc
284 if not isinstance(data, dict):
285 raise ValueError("diagnostic input must be a JSON object")
286 return data
287
288
289def diagnose_file(

Calls 1