Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

added 216 characters in body; edited title
Source Link
Bojangles
  • 101.8k
  • 50
  • 175
  • 209

jquery - parsing Parsing JSON array within array

I have the following code that gets the first 'name' in an array called 'feeds' within my JSON, I would like to now loop through the JSON and get each name. I haven't been able to get that loop to work.

JSON:

{"title":"Testing","created_at":"2011年10月05日T16:23:26.217Z","feeds":[{"0":{"name":"twitter","key":"person1"},"1":{"name":"twitter","key":"person2"},"_id":"4e8c847e02edc10035000003"}]}

This gets the first title successfully:

$.getJSON(getthisshit, function(myJson) {
 var myfeed = myJson.feeds[0][0].name;
 alert(myfeed);
});

I tried to loop through doing something like this, but have not been able to get it to work:

$.getJSON(getthisshit, function(myJson){
 $.each(myJson.feeds, function(i,item){
 alert(item.name);
 });​
});

jquery - parsing JSON array within array

I have the following code that gets the first 'name' in an array called 'feeds' within my JSON, I would like to now loop through the JSON and get each name. I haven't been able to get that loop to work.

JSON:

{"title":"Testing","created_at":"2011年10月05日T16:23:26.217Z","feeds":[{"0":{"name":"twitter","key":"person1"},"1":{"name":"twitter","key":"person2"},"_id":"4e8c847e02edc10035000003"}]}

This gets the first title successfully:

$.getJSON(getthisshit, function(myJson) {
 var myfeed = myJson.feeds[0][0].name;
 alert(myfeed);
});

I tried to loop through doing something like this, but have not been able to get it to work:

$.getJSON(getthisshit, function(myJson){
 $.each(myJson.feeds, function(i,item){
 alert(item.name);
 });​
});

Parsing JSON array within array

I have the following code that gets the first 'name' in an array called 'feeds' within my JSON, I would like to now loop through the JSON and get each name. I haven't been able to get that loop to work.

JSON:

{"title":"Testing","created_at":"2011年10月05日T16:23:26.217Z","feeds":[{"0":{"name":"twitter","key":"person1"},"1":{"name":"twitter","key":"person2"},"_id":"4e8c847e02edc10035000003"}]}

This gets the first title successfully:

$.getJSON(getthisshit, function(myJson) {
 var myfeed = myJson.feeds[0][0].name;
 alert(myfeed);
});

I tried to loop through doing something like this, but have not been able to get it to work:

$.getJSON(getthisshit, function(myJson){
 $.each(myJson.feeds, function(i,item){
 alert(item.name);
 });​
});
Source Link
tuddy
  • 1.8k
  • 4
  • 31
  • 36

jquery - parsing JSON array within array

I have the following code that gets the first 'name' in an array called 'feeds' within my JSON, I would like to now loop through the JSON and get each name. I haven't been able to get that loop to work.

JSON:

{"title":"Testing","created_at":"2011年10月05日T16:23:26.217Z","feeds":[{"0":{"name":"twitter","key":"person1"},"1":{"name":"twitter","key":"person2"},"_id":"4e8c847e02edc10035000003"}]}

This gets the first title successfully:

$.getJSON(getthisshit, function(myJson) {
 var myfeed = myJson.feeds[0][0].name;
 alert(myfeed);
});

I tried to loop through doing something like this, but have not been able to get it to work:

$.getJSON(getthisshit, function(myJson){
 $.each(myJson.feeds, function(i,item){
 alert(item.name);
 });​
});
lang-js

AltStyle によって変換されたページ (->オリジナル) /