如何操纵normalizePayload
中的一个值(无论如何我需要将结果转换为会话)
我需要将start_time和end_time与1000相乘,以便顺利进入attr('date')
"result": [
{
"end_time": 1412687629.42063,
"start_time": 1412687629.26851,
},
{
"end_time": 1412688377.15329,
"start_time": 1412688377.11507,
},
...
我目前的代码是:
App.SessionSerializer = DS.ActiveModelSerializer.extend({
normalizePayload: function(payload) {
return {
sessions: payload.result
};
}
});
答案 0 :(得分:0)
对不起,我在你的另一个问题的答案中给了你不好的信息。 normalizePayload
方法应直接操作payload
哈希:
App.SessionSerializer = DS.ActiveModelSerializer.extend({
normalizePayload: function(payload) {
payload.sessions= payload.result;
delete payload.result;
delete payload.metadata;
return payload;
}
});