Reputation: 3
Here is my JSON array which I need to parse using javascript code.
{ "individualTicketList": [{ "TicketID": 58, "ResponderID": 1, "Subject": "test sub", "DueByDate": "2021-10-12" }, { "TicketID": 59, "ResponderID": 1, "Subject": "test", "DueByDate": "2021-10-12" }] }
I am having an above json array and i need to display subject of each object from my json `which is inside individualticketlist here is my code.`
for(var i=0;i<jsonString.length;i++)
{
alert(a.individualTicketList[i].DueByDate);
}
Upvotes: 0
Views: 52
Reputation: 671
Here's how to loop through it
let json = {
"individualTicketList": [{
"TicketID": 58,
"ResponderID": 1,
"Subject": "test sub",
"DueByDate": "2021-10-12"
}, {
"TicketID": 59,
"ResponderID": 1,
"Subject": "test",
"DueByDate": "2021-10-12"
}]
}
let arr = json["individualTicketList"]
for (var i = 0; i < arr.length; i++) {
console.log(arr[i].Subject);
console.log(arr[i].DueByDate);
//your other code here
}
Upvotes: 1