import SerializerInterface from 'serializerjs/src/Serializer/SerializerInterface.js'
SerializerInterface
Direct Subclass:
Indirect Subclass:
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 |
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.
Return:
* |
public serialize(data: *, format: string, context: *): * source
Serializes any data object into and object usable for the backend service.
Params:
Name | Type | Attribute | Description |
data | * | Any data |
|
format | string | Format the normalization result will be encoded as |
|
context | * |
|
Options serializers have access to |
Return:
* |
public supportsDeserialize(data: *, className: string, format: string): boolean source
Checks whether the given class is supported for deserialization by this serializer.