Ember Data Serializer Data Mapping
I'm using ember & ember-data to try and consume a json feed from the server. Here is my code: App = Ember.Application.create(); DS.RESTAdapter.configure( 'plurals', {
Solution 1:
You have 2 options
- make your server compatible, and let it returns the json as ember data expects it,
- write your own adapter/serializer to support this format.
UPDATE: write your own serializer UPDATE 2: get rid of unused functions
You can inherit from the DS.RESTSerializer
and change extract
with this code
extract: function(loader, json, type, record) {
var root = 'data';
if (json[root]) {
if (record) { loader.updateId(record, json[root]); }
this.extractRecordRepresentation(loader, type, json[root]);
}
}
This assumes that the content of request will always be under the data
key of your json.
Post a Comment for "Ember Data Serializer Data Mapping"