DS.JSONSerializer#serializeAttribute()

serializeAttribute (snapshot, json, key, attribute)

Defined in addon/serializers/json.js:1106

serializeAttribute can be used to customize how DS.attr properties are serialized

For example if you wanted to ensure all your attributes were always serialized as properties on an attributes object you could write:

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

export default DS.JSONSerializer.extend({
  serializeAttribute: function(snapshot, json, key, attributes) {
    json.attributes = json.attributes || {};
    this._super(snapshot, json.attributes, key, attributes);
  }
});

Parameters:

snapshot DS.Snapshot
json Object
key String
attribute Object
doc_EmberJs
2016-11-30 16:49:57
Comments
Leave a Comment

Please login to continue.