简体   繁体   English

如何将对象数组转换为键对值

[英]How can i convert array of objects into key pair value

I am storing messages inside my msges field. 我将消息存储在我的msges字段中。 This is the format 这是格式

在此处输入图片说明

I called ajax and it is returning me the data in this format 我叫ajax,它以这种格式返回数据

[ 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 或者您可以使用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
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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