# ConverterService Service

Module
import { ConverterService } from "@tsed/common"
Source/packages/common/src/converters/services/ConverterService.ts

# Overview

class ConverterService {
    constructor(injectorService: InjectorService, configuration: Configuration);
    static getPropertyMetadata(properties: Map<string | symbol, PropertyMetadata>, propertyKey: string | symbol): PropertyMetadata | undefined;
    serialize(obj: any, options?: IConverterOptions): any;
    serializeClass(obj: any, options?: IConverterOptions): any;
    deserialize(obj: any, targetType: any, baseType?: any, options?: IConverterOptions): any;
    getConverter(targetType: any): IConverter | undefined;
}

# Members

static getPropertyMetadata(properties: Map<string | symbol, PropertyMetadata>, propertyKey: string | symbol): PropertyMetadata | undefined

Return a JsonMetadata for a properties.


serialize(obj: any, options?: IConverterOptions): any

Convert instance to plainObject.

# Options

  • checkRequiredValue: Disable the required check condition.

serializeClass(obj: any, options?: IConverterOptions): any

deserialize(obj: any, targetType: any, baseType?: any, options?: IConverterOptions): any
Param Type Description
obj any Object source that will be deserialized targetType

Convert a plainObject to targetType.

# Options

  • ignoreCallback: callback called for each object which will be deserialized. The callback can return a boolean to avoid the default converter behavior.
  • checkRequiredValue: Disable the required check condition.

getConverter(targetType: any): IConverter | undefined