import json

def dump_json(label: str, data: object, max_chars: int = 8000) -> None:
    """
    Stampa JSON in modo controllato (troncato).
    """
    s = json.dumps(data, ensure_ascii=False, sort_keys=True)
    if len(s) > max_chars:
        s = s[:max_chars] + f"... [truncated {len(s)-max_chars} chars]"
    print(f"{label}: {s}", flush=True)
