js ...

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/themagickeyjianan/article/details/88081897
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' } ]
 */

猜你喜欢

转载自blog.csdn.net/themagickeyjianan/article/details/88081897