Deprecation Notice: This answer is from 2013, and hasn't been touched up until now. This does not reflect JSON API Adapter but rather Ember-Data's RESTAdapter.
Ember.js relies on naming conventions, and it expects that multiple-word-camel-case (e.g. firstName
) model properties to be mapped to multiple-word-underscore-separated-lower-case attributes (e.g. first_name
) on the JSON response. If your JSON is giving you firstName
, or anything that is not in this convention in a scenario that you do not control the backend API, you have the option of defining a map
which tells your adapter to look for a specific key in the JSON response and map it to a property in a given Model.
You can do something like this:
DS.RESTAdapter.map('App.User', {
firstName: { key: 'firstName' },
lastName: { key: 'familyName' }
});
Note that in the sample above I've added a lastName
property which is not part of your own model. I've done that just to make it clear that you can map several properties at the same time, and its name in the JSON response can be anything, not necessarily the same name in a different casing.