Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Duda para recojer valores de array en JSON

Estas en el tema de Duda para recojer valores de array en JSON en el foro de Frameworks JS en Foros del Web. Hola, Le comento tengo un archivo en formato JSON desde el cual tomo algunos valores, a este archivo se le agregó un nuevo array (SetList) ...
  #1 (permalink)  
Antiguo 15/11/2011, 17:22
 
Fecha de Ingreso: noviembre-2008
Mensajes: 67
Antigüedad: 15 años, 5 meses
Puntos: 1
Pregunta Duda para recojer valores de array en JSON

Hola,

Le comento tengo un archivo en formato JSON desde el cual tomo algunos valores, a este archivo se le agregó un nuevo array (SetList) con nuevas variable y no logro resolver el planeto para pode extraer los valores de las variables en el array. Todo ayuda sera bienvenida. Gracias


Fuente:

Código:
{"Genero 1" : [ 
{"id" : "404","videoType" : "guestapt","fps" : "24","isWideScreen" : "1","published" : "Wed, 15 Jun 2011 11:43:22 -0400","title" : "The Guest Apartment - 6.15.2011","thumbnail" : "http://bandcontent.com/imagen-150.jpg","url" : "http://web.net/Marling_Session_768_1500.mp4", "SetList":{"songs":[{"song":"Interview","start":"0","end":"1488"},{"song":"Sophia","start":"1889","end":"7872"},{"song":"Interview","start":"7873","end":"8832"},{"song":"Rest in the Bed","start":"8833","end":"13008"},{"song":"Interview","start":"13009","end":"16608"},{"song":"The Muse","start":"16609","end":"21120"},{"song":"Interview","start":"21121","end":"23328"}]}}
,
{"id" : "402","videoType" : "guestapt","fps" : "24","isWideScreen" : "1","published" : "Fri, 29 Jul 2011 11:28:36 -0400","title" : "he Bowery Electric - 7.29.2011","thumbnail" : "http://bandcontent.com/imagen-151.jpg","url" : "http://web.net/Goulding_Session_1500.mp4", "SetList":{"songs":[{"song":"Guns and Horses","start":"0","end":"7084"},{"song":"Interview","start":"7085","end":"9253"},{"song":"Lights","start":"9254","end":"14166"},{"song":"Interview","start":"14167","end":"16532"},{"song":"Starry Eyed","start":"16533","end":"20839"},{"song":"Interview","start":"20840","end":"22436"}]}}
]

Código JS

Código:
  $.getJSON('fuente.txt', function(sources){
   
    for (var i=0; i<categories.length; i++) {
		var catName = categories[i];

		var category = {
			name: catName,
			videos: [],
			SetList: [],
		};
   
      for (var j=0; j<sources[catName].length; j++) {
        var videoInfo = sources[catName][j];
        var video = {
			thumb: videoInfo.thumbnail,
			title: videoInfo.title,
			subtitle: '',
			description: [],
			sources: [videoInfo.url]
			};
			
			
			//Compruebo si existe SetList
			if(typeof(SetList) !== 'undefined') {
				var SetList = {
					
				};		
			}
			
   
        category.videos.push(video);
      }
      data.categories.push(category);
    }
    startCallback(data);
  });

Etiquetas: js, json, recojer
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:45.