DS.RESTSerializer#serializeIntoHash()

serializeIntoHash (hash, typeClass, snapshot, options)

Inherited from DS.JSONSerializer but overwritten in addon/serializers/rest.js:663

You can use this method to customize the root keys serialized into the JSON. The hash property should be modified by reference (possibly using something like _.extend) By default the REST Serializer sends the modelName of a model, which is a camelized version of the name.

For example, your server may expect underscored root objects.

app/serializers/application.js
import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  serializeIntoHash: function(data, type, record, options) {
    var root = Ember.String.decamelize(type.modelName);
    data[root] = this.serialize(record, options);
  }
});

Parameters:

hash Object
typeClass DS.Model
snapshot DS.Snapshot
options Object
doc_EmberJs
2016-11-30 16:50:37
Comments
Leave a Comment

Please login to continue.