1 回答
TA贡献1835条经验 获得超7个赞
var obj = {"mm37_160d_99_00.gif":"SH/DAzRtH4102.gif","mm37_160d_99_01.gif":"SH/DAzRtH42102.gif","mm37_160d_98_01.gif":"SH/DAzDuq6ik357.gif","mm89_160d_99_02.gif":"SH/DAzw583.gif"};
function formatObj(obj){
var keys = Object.keys(obj);
var resultObj = {};
for (var i=0;i<keys.length;i++){
var bigCategory = keys[i].slice(2,4);
var smallCategory = keys[i].slice(10,12);
resultObj[bigCategory] = Object.assign({},resultObj[bigCategory]);
resultObj[bigCategory][smallCategory]= Object.assign({},resultObj[bigCategory][smallCategory]);
resultObj[bigCategory][smallCategory][keys[i]] = obj[keys[i]];
}
return resultObj;
}
添加回答
举报