You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

11 lines
348 B

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