Some checks failed
Build Simulation and Test / Run All Tests (push) Failing after 8m17s
Major rewrite.
20 lines
518 B
Python
20 lines
518 B
Python
"""JSON formatter for output data."""
|
|
|
|
import json
|
|
from typing import Any
|
|
from .base_formatter import BaseFormatter
|
|
|
|
|
|
class JSONFormatter(BaseFormatter):
|
|
"""Formats data as JSON."""
|
|
|
|
def __init__(self, indent: int = 2):
|
|
self.indent = indent
|
|
|
|
def format(self, data: Any) -> str:
|
|
"""Format data as JSON string."""
|
|
return json.dumps(data, indent=self.indent, default=str)
|
|
|
|
def get_file_extension(self) -> str:
|
|
"""Get file extension for JSON format."""
|
|
return "json" |