Service that manages (de-)serialization of objects.

Hierarchy

  • Serialization

Constructors

Properties

injector: Container
serializers: Collection<RegisteredSerializer<Serializer<unknown, JSONState>>> = ...

Serializers registered with the service. We store the DI keys and realize them as needed, rather than at register time since most registration is done via the

Object Serializer

decorator and the ContainerBlueprint. Realizing them at that time can cause loops in the DI call to realizeContainer since getContainer() -> realizeContainer() -> make the serializer -> getContainer(). This largely defers the realization until after all the DI keys are registered with the global Container.

Methods

  • Decode a value from JSON using a registered serializer, if one exists.

    Throws

    NoSerializerError

    Type Parameters

    • T

    Parameters

    • payload: string
    • Optional validator: Validator<T>

    Returns Promise<T>

  • Encode a value to JSON using a registered serializer, if one exists.

    Throws

    NoSerializerError

    Type Parameters

    • T

    Parameters

    • value: T

    Returns Promise<string>