简体   繁体   中英

How can i convert array of objects into key pair value

I am storing messages inside my msges field. This is the format

在此处输入图片说明

I called ajax and it is returning me the data in this format

[ object, object, object ]

I want to convert it into an array with object keys and object values. How can I do that?

You have read values as object

//result is the result of the query
    for (var line in result) {
    //acces to uname by line.uname
    //acces to email by line.email
    }

Hope that will help you

Or you can use for each

//result is the result of the query
        for each(line in result) {
        //acces to uname by line.uname
        //acces to email by line.email
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM