# Class ConverterService

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

# Overview

class ConverterService {
<span class="token keyword">constructor</span><span class="token punctuation">(</span>injectorService<span class="token punctuation">:</span> <a href="/api/di/services/InjectorService.html"><span class="token">InjectorService</span></a><span class="token punctuation">,</span> configuration<span class="token punctuation">:</span> <a href="/api/di/decorators/Configuration.html"><span class="token">Configuration</span></a><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token function">serialize</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/json-mapper/utils/JsonSerializerOptions.html"><span class="token">JsonSerializerOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

<span class="token function">serialize</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/common/mvc/services/ConverterOptions.html"><span class="token">ConverterOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

<span class="token function">serializeClass</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/common/mvc/services/ConverterOptions.html"><span class="token">ConverterOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token function">deserialize</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/json-mapper/utils/JsonDeserializerOptions.html"><span class="token">JsonDeserializerOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">deserialize</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> type<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/common/mvc/services/ConverterOptions.html"><span class="token">ConverterOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

<span class="token function">deserialize</span><span class="token punctuation">(</span>obj<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> collectionType<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> baseType<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/common/mvc/services/ConverterOptions.html"><span class="token">ConverterOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

}

# Members

serialize(obj: any, options?: JsonSerializerOptions): any;

Convert instance to plainObject.


serialize(obj: any, options?: ConverterOptions): any;

serializeClass(obj: any, options?: ConverterOptions): {};

deserialize(obj: any, options?: JsonDeserializerOptions): any;
Param Type Description
obj any Object source that will be deserialized options

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.

deserialize(obj: any, type: any, options?: ConverterOptions): any;

deserialize(obj: any, collectionType: any, baseType: any, options?: ConverterOptions): any;

Other topics