Skip to content

PrimitiveMapper

@tsed/json-mapper

Usage ​

typescript
import { PrimitiveMapper } from "@tsed/json-mapper";

See /packages/specs/json-mapper/src/components/PrimitiveMapper.ts.

Overview ​

ts
class PrimitiveMapper implements JsonMapperMethods {
    deserialize<T>(data: any, ctx: JsonMapperCtx): string | number | boolean | void | null | BigInt;
    serialize(object: string | number | boolean | BigInt, ctx: JsonMapperCtx): string | number | boolean | BigInt;
    protected String(data: any): string | null;
    protected Boolean(data: any): boolean | null | undefined;
    protected Number(data: any): any;
    protected BigInt(data: any): bigint | null;
}

Description ​

Mapper for the String, Number, BigInt and Boolean types.

deserialize ​

ts
deserialize<T>(data: any, ctx: JsonMapperCtx): string | number | boolean | void | null | BigInt;

serialize ​

ts
serialize(object: string | number | boolean | BigInt, ctx: JsonMapperCtx): string | number | boolean | BigInt;

protected String ​

ts
protected String(data: any): string | null;

protected Boolean ​

ts
protected Boolean(data: any): boolean | null | undefined;

protected Number ​

ts
protected Number(data: any): any;

protected BigInt ​

ts
protected BigInt(data: any): bigint | null;

Released under the MIT License.