I need to get the values from JSON and show them in a HTML table.
Below is my JSON:
[
{
"id": "3",
"title": "Doing Business In...",
"businessSubjectAreas": [
{
"businessSubjectArea": "Market and Sell Products/Service"
},
{
"businessSubjectArea": "Deliver Products/Services"
},
{
"businessSubjectArea": "HR"
},
{
"businessSubjectArea": "Legal"
},
{
"businessSubjectArea": "Finance"
},
{
"businessSubjectArea": "Tax"
},
{
"businessSubjectArea": "Treasury"
},
{
"businessSubjectArea": "IT"
}
],
"attachmentFiles": [
{
"fileName": "Australia.html",
"url": ""
}
],
"error": null
},
{
"id": "65",
"title": "Dialing Instructions",
"businessSubjectAreas": [
{
"businessSubjectArea": "Administrative"
}
],
"attachmentFiles": [
],
"error": null
},
{
"id": "132",
"title": "WA - Western Australia - Drilling Fluid Management",
"businessSubjectAreas": [
{
"businessSubjectArea": "Market and Sell Products/Service"
},
{
"businessSubjectArea": "Deliver Products/Services"
},
{
"businessSubjectArea": "Legal"
}
],
"attachmentFiles": [
{
"fileName": "",
"url": ""
}
],
"error": null
},
{
"id": "133",
"title": "WA - Natural gas from shale and tight rock - Overview of WA regulatory framework",
"businessSubjectAreas": [
{
"businessSubjectArea": "Market and Sell Products/Service"
},
{
"businessSubjectArea": "Deliver Products/Services"
},
{
"businessSubjectArea": "Legal"
}
],
"attachmentFiles": [
{
"fileName": "",
"url": ""
}
],
"error": null
}
]
Below is my jQuery code:
$.each(json, function(index, value) {
$("#id_kbdata").append(
" <tr><td style='text-align:left;font-family:arial;padding:5px 10px;border-bottom:1px solid #ccc;border-right:1px solid #ccc;width:33%;'>" +
this.title +
"</td><td style='text-align:left;font-family:arial;padding:5px 10px;border-bottom:1px solid #ccc;border-right:1px solid #ccc;width:33%;'> "
+
"<ul>" +
$.each(this.businessSubjectAreas, function(index, value) {
"<li>" + this.businessSubjectArea + "</li>"
}) +
"</ul>" +
" </td><td style='text-align:left;font-family:arial;padding:5px 10px;border-bottom:1px solid #ccc;border-right:1px solid #ccc;width:33%;'> "
+
"<ul>" +
$.each(this.attachmentFiles, function(index, value) {
"<li><a href=" + this.url + ">" + this.fileName + "</a></li>"
}) +
"</ul>" +
" </td></tr>"
);
});
Here I am unable to get the values from JSON with inner each loop like this.businessSubjectArea, I am getting those values as [object Object], this.title is working fine. I have removed values from JSON as it is sensitive data.
How can I access the values this.businessSubjectArea, this.url etc. with my jQuery code?
value.businessSubjectArea