I am trying to parse the following JSON feed into HTML, but not getting any results.
{
@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"
}
With this jQuery:
$.getJSON("https://json-feed-url.json", function (data) {
var jsondata = json;
var output = "<ul>";
for (var i in jsondata.events) {
output += "<li>"
+ jsondata.component[i].name + " "
+ jsondata.component[i].url + "--"
+ jsondata.license[i].licensetext
+ "</li>";
}
output += "</ul>";
document.getElementById("content").innerHTML = output;
});
To this div
<div id="content"></div>
Not sure why its not parsing correctly. Here's a jsFiddle.
{"@name": "App name"Also, on the other hand, for cross-domain requests you would need JSONp."@name"instead of@name,"license"instead oflicense, etc.