Print data as JSON with optional field filtering. Args: data: Data to output fields: Fields to include (None for all)
(data: Any, fields: list[str] | None = None)
| 221 | |
| 222 | |
| 223 | def print_json(data: Any, fields: list[str] | None = None) -> None: |
| 224 | """Print data as JSON with optional field filtering. |
| 225 | |
| 226 | Args: |
| 227 | data: Data to output |
| 228 | fields: Fields to include (None for all) |
| 229 | """ |
| 230 | filtered = filter_fields(data, fields) |
| 231 | if console.no_color: |
| 232 | print(json.dumps(filtered, ensure_ascii=False, indent=2)) |
| 233 | else: |
| 234 | console.print_json(json.dumps(filtered, ensure_ascii=False)) |
| 235 | |
| 236 | |
| 237 | def print_error(message: str, code: str | None = None) -> None: |