User blog:Jens Ingels/API project

This is a work in progress script that would convert the riot API in structured data:

api = api["data"]; var info; for (var key in api) { if (api.hasOwnProperty(key)) { var obj = api[key]; for (var prop in obj) { if(obj.hasOwnProperty(prop)){ //console.log(prop + " = " + obj[prop]); if(prop === "id"){ info += ''; } else if(prop === "name"){ info += '' + obj[prop] + ' '; } else if(prop === "into"){ info += ' Build Into '; items = obj[prop]; //console.log(items); for (i = 0; i < items.length; i++) { items2 = items[i]; console.log(api[items2].name); info += '' + api[items2].name + ''; }							info += ' '; } else if(prop === "stats"){ info += ' Stats ' obj2 = api[key].stats for (var prop2 in obj2) { //console.log(prop2); info += '' + obj2[prop2] + ' '; }						} else if(prop === "gold"){ info += ' Gold  Base: ' + obj[prop]["base"] + ' Total: ' + obj[prop]["total"] + ' Sell: ' + obj[prop]["total"] + ' Purchasable: ' + obj[prop]["purchasable"] + ' '; }						else { info += '' + obj[prop] + ' '; }					}			  }			   info += ' '; }		}		document.getElementById("items").innerHTML = info;