Hi,
I have a model class Item which looks like this:
export default class ItemModel extends Model {
@attr name;
@attr description;
@attr quantityInfo;
}
QuantityInfo has some nested attributes but since it is embedded object with no id I don’t want to create another model for it (according to Defining Models - Ember Data - Ember Guides ).
I’m connecting with json API which uses snake case so I made ItemSerializer which extends JSONSerializer.extend(EmbeddedRecordsMixin)
.
In this serializer I add method:
export default class ItemModel extends Model {
@attr name;
@attr description;
@attr quantityInfo;
keyForAttribute(key) {
return underscore(key);
}
}
.
The problem is that nested attributes are not serialized in the underscore way. This is the output json:
{
"name":"Cola 0.5",
"description":"asd",
"quantity_info":{
"defaultQuantity":0
}
}
Is there any simple solution to solve this problem?