Skip to content

@jsvision/core / serializeTheme

Function: serializeTheme()

serializeTheme(theme): string

Defined in: color/serialize.ts:84

Serialize a theme to a JSON string.

The result is a { "version": 1, "roles": { … } } envelope; roles appear in the canonical order and each role's keys in a fixed order, so two equal themes serialize to byte-identical strings. Round-trips losslessly through parseTheme, including the desktop pattern glyph and any attrs.

Parameters

theme

Theme

The theme to serialize.

Returns

string

A pretty-printed JSON string (no filesystem access — a pure string).

Example

ts
import { serializeTheme, defaultTheme } from '@jsvision/core';

const json = serializeTheme(defaultTheme); // '{ "version": 1, "roles": { … } }'