このように、OrderItemId にアクセスする場合
var test = {"1":
[
{"OrderItemId":832,"ItemId":995,"Price":0},
{"OrderItemId":833,"ItemId":997,"Price":0},
{"OrderItemId":834,"ItemId":999,"Price":0}
],
"2":
[
{"OrderItemId":835,"ItemId":1008,"Price":0},
{"OrderItemId":836,"ItemId":1057,"Price":0}
]
}
alert(test["1"][0]['OrderItemId']);
alert(test["1"][1]['OrderItemId']);
alert(test["1"][2]['OrderItemId']);
alert(test["2"][0]['OrderItemId']);
alert(test["2"][1]['OrderItemId']);
UPDATE、不明な長さでトラフ テストを繰り返す
for (var i=0;i<test["1"].length;i++) {
alert(test["1"][i]['OrderItemId']);
}
ここでは全自動列挙
var number, count = 0;
var en = [];
for(number in test) {
en[count]=number;
count++;
}
for (var r=0;r<en.length;r++) {
alert(en[r]);
for (var i=0;i<test[en[r]].length;i++) {
alert(test[en[r]][i]['OrderItemId']);
}
}