How do I iterate through this json message’s nested array(i.e. “orders”) with jquery?
[{"Type":"X","Symbol":"AAP","BidPrice":17.0,
"OfferPrice":0.0,"BidQty":9,"OfferQty":0,"LastTradePrice":17.0,
"orders":[{"BidQuantity":"12","BidPrice":"17.0","OfferQuantity":"","OfferPrice":""},
"BidQuantity":"5","BidPrice":"17.0","OfferQuantity":"","OfferPrice":""},
"BidQuantity":"5","BidPrice":"17.0","OfferQuantity":"","OfferPrice":""},
"BidQuantity":"2","BidPrice":"16.0","OfferQuantity":"","OfferPrice":""}]}
I have tried the following way but it does not work
$.each(data, function(i, item) {
$('#last').text(data[i].LastTradePrice);
var ords = item.orders;
$.each(ords, function(x,ork) {
alert(ork[x].BidPrice);
});
});
I get the following error in firefox console
ork[x] is undefined
Changing my code to following way it worked for me perfectly well.
Sorry for the delayed response with the answer, I was seriously busy with work for a while……
Thanks all who tried to help.