serializeIntoHash (hash, typeClass, snapshot, options)
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
Please login to continue.