Serializer interface

Used to map raw response objects to final shapes. Helps packing and unpacking Dates and other encoded types that are not intrinsic to JSON. Also allows pulling values from headers, as well as inserting default values and constants.

Properties

isXML

Whether the contents are XML or not.

modelMappers

The provided model mapper.

Methods

deserialize(Mapper, any, string, SerializerOptions)

Deserialize the given object based on its metadata defined in the mapper.

serialize(Mapper, any, string, SerializerOptions)

Serialize the given object based on its metadata defined in the mapper.

validateConstraints(Mapper, any, string)

Validates constraints, if any. This function will throw if the provided value does not respect those constraints.

Property Details

isXML

Whether the contents are XML or not.

isXML: boolean

Property Value

boolean

modelMappers

The provided model mapper.

modelMappers: {[key: string]: any}

Property Value

{[key: string]: any}

Method Details

deserialize(Mapper, any, string, SerializerOptions)

Deserialize the given object based on its metadata defined in the mapper.

function deserialize(mapper: Mapper, responseBody: any, objectName: string, options?: SerializerOptions): any

Parameters

mapper
Mapper

The mapper which defines the metadata of the serializable object.

responseBody

any

A valid Javascript entity to be deserialized.

objectName

string

Name of the deserialized object.

options
SerializerOptions

Controls behavior of XML parser and builder.

Returns

any

A valid deserialized Javascript object.

serialize(Mapper, any, string, SerializerOptions)

Serialize the given object based on its metadata defined in the mapper.

function serialize(mapper: Mapper, object: any, objectName?: string, options?: SerializerOptions): any

Parameters

mapper
Mapper

The mapper which defines the metadata of the serializable object.

object

any

A valid Javascript object to be serialized.

objectName

string

Name of the serialized object.

options
SerializerOptions

additional options to deserialization.

Returns

any

A valid serialized Javascript object.

validateConstraints(Mapper, any, string)

Warning

This API is now deprecated.

Removing the constraints validation on client side.

Validates constraints, if any. This function will throw if the provided value does not respect those constraints.

function validateConstraints(mapper: Mapper, value: any, objectName: string)

Parameters

mapper
Mapper

The definition of data models.

value

any

The value.

objectName

string

Name of the object. Used in the error messages.