_load

ClawTeam-OpenClaw · files, json-parsing, config-loading, file-reading, fallback-handling

Reads and parses a JSON file from a given path, returning an empty dict if the file is missing or invalid. Ensures safe, fallback-driven config loading.

def _load(path: Path) -> dict:
    if path.exists():
        try:
            return json.loads(path.read_text())
        except (json.JSONDecodeError, OSError):
            return {}
    return {}

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key