Class DS.JSONAPISerializer
Extends:
DS.JSONSerializer
Module:
ember-data
Ember Data 2.0 Serializer:
In Ember Data a Serializer is used to serialize and deserialize records when they are transferred in and out of an external source. This process involves normalizing property names, transforming attribute values and serializing relationships.
JSONAPISerializer
supports the http://jsonapi.org/ spec and is the
serializer recommended by Ember Data.
This serializer normalizes a JSON API payload that looks like:
// models/player.js
import DS from "ember-data";
export default DS.Model.extend({
name: DS.attr(),
skill: DS.attr(),
gamesPlayed: DS.attr(),
club: DS.belongsTo('club')
});
// models/club.js
import DS from "ember-data";
export default DS.Model.extend({
name: DS.attr(),
location: DS.attr(),
players: DS.hasMany('player')
});
{
"data": [
{
"attributes": {
"name": "Benfica",
"location": "Portugal"
},
"id": "1",
"relationships": {
"players": {
"data": [
{
"id": "3",
"type": "players"
}
]
}
},
"type": "clubs"
}
],
"included": [
{
"attributes": {
"name": "Eusebio Silva Ferreira",
"skill": "Rocket shot",
"games-played": 431
},
"id": "3",
"relationships": {
"club": {
"data": {
"id": "1",
"type": "clubs"
}
}
},
"type": "players"
}
]
}
to the format that the Ember Data store expects.
Methods
- extract
- extractArray
- extractAttributes
- extractCreateRecord
- extractDeleteRecord
- extractErrors
- extractFind
- extractFindAll
- extractFindBelongsTo
- extractFindHasMany
- extractFindMany
- extractFindQuery
- extractId
- extractMeta
- extractQueryRecord
- extractRelationship
- extractRelationships
- extractSave
- extractSingle
- extractUpdateRecord
- keyForAttribute
- keyForLink
- keyForRelationship
- modelNameFromPayloadKey
- normalize
- normalize
- normalizeArrayResponse
- normalizeCreateRecordResponse
- normalizeDeleteRecordResponse
- normalizeFindAllResponse
- normalizeFindBelongsToResponse
- normalizeFindHasManyResponse
- normalizeFindManyResponse
- normalizeFindRecordResponse
- normalizeQueryRecordResponse
- normalizeQueryResponse
- normalizeResponse
- normalizeSaveResponse
- normalizeSingleResponse
- normalizeUpdateRecordResponse
- payloadKeyFromModelName
- pushPayload
- serialize
- serialize
- serializeAttribute
- serializeBelongsTo
- serializeHasMany
- serializeIntoHash
- serializePolymorphicType
Properties
Events
No documented items