Home Manual Reference Source Test Repository
import SerializerInterface from 'serializerjs/src/Serializer/SerializerInterface.js'
public interface | source

SerializerInterface

Direct Subclass:

Serializer, SerializerAware

Indirect Subclass:

AbstractSerializer

A serializer is responsible for transforming a data in a specific format into a data in another format.

For example, the serializer can be used to map client-side models and back-end side objects by checking all the properties of a model to generate an object for which the values are understandable for the back-end service.

+--------+ ----- serialize -----> +----------+ | Client | | Back-End | +--------+ <---- deserialize ---- +----------+

Note that JavaScript does not support interfaces per se. By "Interface" is meant that this class should not implement any method but provide the skeleton for child classes instead.

Test:

Method Summary

Public Methods
public

deserialize(data: *, className: string, format: string, context: *): *

Deserializes data back into an object of the given class.

public

serialize(data: *, format: string, context: *): *

Serializes any data object into and object usable for the backend service.

public

supportsDeserialize(data: *, className: string, format: string): boolean

Checks whether the given class is supported for deserialization by this serializer.

public

supportsSerialize(data: *, format: string): boolean

Checks whether the given class is supported for serialization by this serializer.

Public Methods

public deserialize(data: *, className: string, format: string, context: *): * source

Deserializes data back into an object of the given class.

Params:

NameTypeAttributeDescription
data *

Data to restore

className string

The expected class to instantiate

format string
  • optional
  • default: null
  • nullable: true

Format the given data was extracted from

context *
  • optional
  • default: null

Options available to the deserializer

Return:

*

Test:

public serialize(data: *, format: string, context: *): * source

Serializes any data object into and object usable for the backend service.

Params:

NameTypeAttributeDescription
data *

Any data

format string

Format the normalization result will be encoded as

context *
  • optional
  • default: null

Options serializers have access to

Return:

*

Test:

public supportsDeserialize(data: *, className: string, format: string): boolean source

Checks whether the given class is supported for deserialization by this serializer.

Params:

NameTypeAttributeDescription
data *

Data to restore

className string

The expected class to instantiate

format string
  • optional
  • default: null
  • nullable: true

Format the given data was extracted from

Return:

boolean

Test:

public supportsSerialize(data: *, format: string): boolean source

Checks whether the given class is supported for serialization by this serializer.

Params:

NameTypeAttributeDescription
data *

Any data

format string
  • optional
  • default: null

Format the normalization result will be encoded as

Return:

boolean

Test: