mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
This squashes all local history (768 commits) onto the scrubbed PR #90 baseline. Individual commits were lost during filter-repo corruption; the working tree content is preserved intact. Build: N/A (working tree state only)
19 lines
565 B
Python
19 lines
565 B
Python
import json
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
def stable_json(obj: Any) -> str:
|
|
return json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
|
|
|
|
|
|
def canonical_json_bytes(obj: Any) -> bytes:
|
|
return json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
|
|
|
|
|
|
def load_json(path: Path) -> Any:
|
|
return json.loads(path.read_text(encoding="utf-8"))
|
|
|
|
|
|
def load_jsonl(path: Path) -> list:
|
|
return [json.loads(line) for line in path.read_text(encoding="utf-8").strip().splitlines() if line.strip()]
|