serializeAttribute (snapshot, json, key, attribute)
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
Please login to continue.