color_tools.exporters.json_exporter

JSON format exporter for colors and filaments.

Provides a JSON exporter that outputs raw dataclass data in JSON format. Useful for backups, data exchange, and restore operations.

The exporter is automatically registered and available via the exporter registry.

class color_tools.exporters.json_exporter.JSONExporter[source]

Bases: PaletteExporter

JSON format exporter for colors and filaments.

Exports data in JSON format with proper indentation and UTF-8 encoding. Output format is identical to the core data files (colors.json, filaments.json), making this exporter suitable for backups and data restoration.

Features:
  • Pretty-printed with 2-space indentation

  • UTF-8 encoding with non-ASCII characters preserved

  • Dataclass fields exported as-is (tuples become arrays)

Example

>>> from color_tools.exporters import get_exporter
>>> exporter = get_exporter('json')
>>> from color_tools.palette import Palette
>>> palette = Palette.load_default()
>>> path = exporter.export_colors(palette.colors, 'my_colors.json')
property metadata: ExporterMetadata

Return metadata describing this exporter’s capabilities.

Returns:

ExporterMetadata instance with name, description, capabilities