DS.JSONAPISerializer#keyForRelationship()

keyForRelationship (key, typeClass, method) String

Inherited from DS.JSONSerializer but overwritten in addon/serializers/json-api.js:427

keyForRelationship can be used to define a custom key when serializing and deserializing relationship properties. By default JSONAPISerializer follows the format used on the examples of http://jsonapi.org/format and uses dashes as word separators in relationship properties.

This behaviour can be easily customized by extending this method.

Example

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

 export default DS.JSONAPISerializer.extend({
   keyForRelationship: function(key, relationship, method) {
     return Ember.String.underscore(key);
   }
 });

Parameters:

key String
typeClass String
method String

Returns:

String
normalized key
doc_EmberJs
2016-11-30 16:49:43
Comments
Leave a Comment

Please login to continue.