Fast question, here is my Json:

{
    "items": [
        {
            "id": "4cd8fe75d",
            "name": "foo"
        },
        {
            "id": "5076c7e30",
            "name": "bar"
        },
        ......
        {
            "id": "6236c7e30",
            "name": "foobar"
        }
    ]
}

I know I can access the first "name" foo like that: items[0].name But what about the other (and many others following on the string?

Generally: with .each() I can access every value on an array but what about every object in a sequence (not sure if I express my point correctly)

share|improve this question

67% accept rate
feedback

2 Answers

up vote 1 down vote accepted

items[i].name should get the name property of the i'th object in the array.

for(var i=0;i<items.length;i++){
    console.log(items[i].name);
}
share|improve this answer
feedback

Ok it was more obvious than I thought:

$.each(items, function(i,item){
      alert(items[i].name);
      });
share|improve this answer
1  
But this is what i posted too – Asad 14 hours ago
@Asad never ignored you :) I was just stuck – DDL449 10 hours ago
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.