Skip to main content
Version: v2.10.0

JSONUtils

Table of Contentsโ€‹

Class Definitionโ€‹

export abstract class JSONUtils {}
info

JSONUtils is an abstract utility class. All members are static โ€” it cannot be instantiated directly.

Methodsโ€‹

safe()โ€‹

static safe<T>(obj: T, space?: number): string

Serializes a value to a JSON string using safe-stable-stringify, which handles circular references and non-deterministic key ordering safely.

Parametersโ€‹

Parameter Type Description Optional
objTThe value to serialize.
spacenumberIndentation spaces for pretty-printing. Omit for compact output.

Returnsโ€‹

Type Description
stringThe serialized JSON string.

serializeTrack()โ€‹

static serializeTrack(track: Track): string

Serializes a Track to a JSON string. The requester field is reduced to { id, username } to avoid circular references or non-serializable user objects.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track to serialize.

Returnsโ€‹

Type Description
stringThe JSON string representation of the track.