Search code examples
ember.jsember-data

Ember: Serialize arbitrary hash key names


In my model I have an arbitrary hash (DS.attr()) whose properties are returned dasherized. Example,

{
  'lorem-ipsum': 'Some value',
  'dolor-sit': 'Some value'
}

I want the key names to be camelCased. How can I achieve this?


Solution

  • Yes, you can write your custom transform.

    In ember-cli use ember g transform my-custom-transform.

    Then you write DS.attr('my-custom-transform').