DS.Serializer Class addon/serializer.js:7


Extends: Ember.Object

Defined in: addon/serializer.js:7

Module: ember-data

DS.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 DS.JSONSerializer, the included JSON serializer.

Show:

Methods

Properties

Show:

normalize

(typeClass, hash) Object

The normalize method is used to convert a payload received from your external data source into the normalized form store.push() expects. You should override this method, munge the hash and return the normalized payload.

Parameters:

typeClass DS.Model
hash Object

Returns:

Object

normalizeResponse

(store, primaryModelClass, payload, id, requestType) Object

The normalizeResponse method is used to normalize a payload from the server to a JSON-API Document.

http://jsonapi.org/format/#document-structure

Parameters:

store DS.Store
primaryModelClass DS.Model
payload Object
id String|Number
requestType String

Returns:

Object
JSON-API Document

serialize

(record, options) Object

The serialize method is used when a record is saved in order to convert the record into the form that your external data source expects.

serialize takes an optional options hash with a single option:

  • includeId: If this is true, serialize should include the ID in the serialized object it builds.

Parameters:

record DS.Model
options [Object]

Returns:

Object
Show:

store

{DS.Store} public

The store property is the application's store that contains all records. It's injected as a service. It can be used to push records from a non flat data structure server response.