简体   繁体   中英

Get values from object array in jquery

I am having a data like this in jquery how do i get the groupname2 values from the grouplist that user1,user2 etc:

{"groupslist":{"groupname":["user1","user2","user3"],"groupname2":["user1","user2","user3"],"groupname3":["user1","user2","user3"]}}

i have declared grouplist={} and push the groupname values dynamically what i get in console when i print grouplist is `

Object {user00: Array[3], super user: Array[1], supreme user: Array[0]}
super user: Array[1]
0: "sample_vh.com"
length: 1
__proto__: Array[0]
supreme user: Array[0]
user00: Array[3]
0: "veera_tls.com"
1: "v_v.com"
2: "sample_vh.com"
length: 3
__proto__: Array[0]
__proto__: Object`
var o = {
  "groupslist":{
    "groupname":["user1","user2","user3"],
    "groupname2":["user1","user2","user3"],
    "groupname3":["user1","user2","user3"]
  }
};

console.log(o.groupslist.groupname2);

Your data can access like this :

var mylist = {"groupslist":{"groupname":["user1","user2","user3"],"groupname2":["user1","user2","user3"],"groupname3":["user1","user2","user3"]}};
console.log(mylist.groupslist.groupname2)

Example : http://jsfiddle.net/b3jVX/

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