My server needs json in the below format when sending a PUT request. My server is a rest api designed using struts2 rest plugin.
{
id: "5",
empId: "5",
firstName: "oki",
lastName: "iko",
edQual: "phd"
}
but the RESTAdapter serializes it to
[
employees:
{
id: "5",
empId: "5",
firstName: "oki",
lastName: "iko",
edQual: "phd"
}
]
I tried ignoring properties in backend but that just ignored the whole json and submitted null values to the sql-server. I need to override or customize the Serialization of ember.js but I dont know how.
This is one of the responsibilities for the Serializer provided by Ember Data. I guess you are using
RestSerializer, which is normally used together withRestAdapteraren't you? In that case you should customize theserializeIntoHash()method. Just not using a namespace at all should be accomplished by:To not loose any data that is already present on
hashyou could useObject.assign(). This is also what's done inJSONSerializer:The
assign || mergeis only needed to support very old ember versions. You could simplify to:You don't need to use the polyfill for
assignif you don't support IE 11. In that case it would be:And with native class it looks like: