2 回答
TA贡献1829条经验 获得超6个赞
您可以使用 Object.values
let data = { "mp3": {
"33274": {
"idSon": 33274,
"description": "Techno Music",
"Typenom": "Billboard",
},
"33275": {
"idSon": 33275,
"description": "Techno Music",
"Typenom": "Pub Cd/Dvd",
}
}
};
let d = {"mp3" : Object.values(data.mp3)}
console.log(d)
TA贡献1828条经验 获得超3个赞
如果您的目标是制作对象数组,则可以使用 Object.values()
let obj = {
"mp3": {
"33274": {
"idSon": 33274,
"description": "Techno Music",
"Typenom": "Billboard",
},
"33275": {
"idSon": 33275,
"description": "Techno Music",
"Typenom": "Pub Cd/Dvd",
}
}
}
obj.mp3 = Object.values(obj.mp3)
console.log(obj)
在您的情况下,您可以初始化resultMp3为数组(let resultMp3 = [];)并替换此行
resultMp3[extraitMp3.idSon] = mp3;
经过
resultMp3.push(mp3);
添加回答
举报