Class Serializer

public

⚠️ CAUTION you likely want the docs for Serializer as extending this abstract class is unnecessary.

Serializer is an abstract base class that you may 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:

1
2
3
4
5
6
7
Serializer.extend({
  extractRelationship(relationshipModelName, relationshipHash) {
    let modelClass = this.store.modelFor(relationshipModelName);
    let relationshipSerializer = this.store.serializerFor(relationshipModelName);
    return relationshipSerializer.normalize(modelClass, relationshipHash);
  }
});