Class Serializer

public

Serializer is an abstract base class that you should override in your application to customize it for your backend. The minimum set of methods that you should implement is:

  • normalizeResponse()
  • serialize()

And you can optionally override the following methods:

  • normalize()

For an example implementation, see JSONSerializer, the included JSON serializer.

Show:

The store property is the application's store that contains all records. It can be used to look up serializers for other model types that may be nested inside the payload response.

Example:

Serializer.extend({
  extractRelationship(relationshipModelName, relationshipHash) {
    let modelClass = this.store.modelFor(relationshipModelName);
    let relationshipSerializer = this.store.serializerFor(relationshipModelName);
    return relationshipSerializer.normalize(modelClass, relationshipHash);
  }
});