var socketMaps = {
"keya": {
"1": "abc",
"a": "123"
},
"keyb": {
"2": "abc1",
"aa": "123123"
}
};
function getAllUsers() {
let allUsers = [];
for(let [key, value] of Object.entries(socketMaps)){
allUsers.push({
id: key,
...value
});
}
return allUsers;
}
console.log("\n getAllUsers =", getAllUsers());
/**
getAllUsers = [ { '1': 'abc', id: 'keya', a: '123' },
{ '2': 'abc1', id: 'keyb', aa: '123123' } ]
*/
转自:https://blog.csdn.net/themagickeyjianan/article/details/88081897