DS.JSONSerializer#serializeIntoHash()

serializeIntoHash (hash, typeClass, snapshot, options)

Defined in addon/serializers/json.js:1075

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
doc_EmberJs
2016-11-30 16:49:58
Comments
Leave a Comment

Please login to continue.