serializeIntoHash (hash, typeClass, snapshot, options)
You can use this method to customize how a serialized record is added to the complete JSON hash to be sent to the server. By default the JSON Serializer does not namespace the payload and just sends the raw serialized JSON object. If your server expects namespaced keys, you should consider using the RESTSerializer. Otherwise you can override this method to customize how the record is added to the hash. The hash property should be modified by reference.
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, snapshot, options) { var root = Ember.String.decamelize(type.modelName); data[root] = this.serialize(snapshot, options); } });
Parameters:
-
hash
Object
-
typeClass
DS.Model
-
snapshot
DS.Snapshot
-
options
Object
Please login to continue.