Quantcast
Channel: Parse JSON feed to HTML with jQuery - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by skobaljic for Parse JSON feed to HTML with jQuery

$
0
0

You have several errors, starting from invalid JSON you posted. Corrected it should work as you can see HERE and below:

var yourJson = {"@name": "App name","license": [{"@name": "Apache License 2.0","component": [{"name": "Product 1","url": "http://www.url.com"        }, {"name": "Product 2","url": "http://www.url.com"        }, {"name": "Product 3","url": "http://www.url.com"        }],"licensetext": " license text here"    }],"isProjectComplete": "true"};function convertJson(data) {    var jsondata = data;    var output = "<ul>";    for (var i in jsondata.license[0].component) {        output += "<li>"+ jsondata.license[0].component[i].name +""+ jsondata.license[0].component[i].url +"--"+ jsondata.license[0].licensetext +"</li>";    }    output += "</ul>";    document.getElementById("content").innerHTML = output;};convertJson(yourJson);

You should be more careful and you should learn to use debugging tools more effective.


Viewing all articles
Browse latest Browse all 3

Trending Articles