Skip to main content
Version: v2.10.5

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.