Skip to content

_json_safe

Internal helper
This page documents an internal implementation helper, not a primary public API.
Source code in src/fabricops_kit/quality.py
1006
1007
1008
1009
1010
1011
1012
1013
def _json_safe(value: Any) -> Any:
    if isinstance(value, (datetime, pd.Timestamp, timedelta)):
        return value.isoformat() if hasattr(value, "isoformat") else str(value)
    if isinstance(value, dict):
        return {k: _json_safe(v) for k, v in value.items()}
    if isinstance(value, list):
        return [_json_safe(v) for v in value]
    return value