[
[
{
"Id": 3,
"Code": "232",
"TicketImage": "0"
}
],
[
{
"Id": 1,
"Code": "23",
"TicketImage": "1"
},
{
"Id": 2,
"Code": "24",
"TicketImage": "1"
}
],
[]
]
I have this JSon object which I m trying to parse.
var res = jQuery.parseJSON(JSON.stringify(obj.Message));
$.each(res, function (i, tickets) {
$.each(tickets, function (i, ticket) {
console.log($(this));
});
});
When i try this i get zillions of popups with letters. but i want object.
How can i parse this JSON data?
UPDATE:
$.each(res, function (i, tickets) {
$.each(tickets, function (i, ticket) {
console.log(ticket.Code);
console.log(ticket.TicketImage);
});
});
This did it.
Careful you are overriding the i variable :
Besides this small thing, your loop is correct, you don’t need the jquery wrapper on your ‘this’. in $.each(array,function(k,v){}) , the k variable is the key to retrieve the current object and v it’s value so you could also access it by doing this :
The same code using ‘this’ :
using each value :