Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The `JSONSerializer` normalization process follows these steps:
- `normalizeResponse` - entry method to the serializer.
- `normalizeCreateRecordResponse` - a `normalizeResponse` for a specific operation is called.
- `normalizeSingleResponse`|`normalizeArrayResponse` - for methods like `createRecord` we expect
a single record back, while for methods like `findAll` we expect multiple records back.
- `normalize` - `normalizeArray` iterates and calls `normalize` for each of its records while `normalizeSingle`
calls it once. This is the method you most likely want to subclass.
- `extractId` | `extractAttributes` | `extractRelationships` - `normalize` delegates to these methods to
turn the record payload into the JSON API format.
@class JSONSerializer
@extends Serializer
*/
const JSONSerializer = Serializer.extend({
/**
The `primaryKey` is used when serializing and deserializing
data. Ember Data always uses the `id` property to store the id of
the record. The external source may not always follow this
convention. In these cases it is useful to override the
`primaryKey` property to match the `primaryKey` of your external
store.
Example
```app/serializers/application.js
import JSONSerializer from '@ember-data/serializer/json';
export default JSONSerializer.extend({
primaryKey: '_id'
});