11
JavaScript วนซ้ำอาร์เรย์ json หรือไม่
ฉันพยายามวนซ้ำอาร์เรย์ json ต่อไปนี้: { "id": "1", "msg": "hi", "tid": "2013-05-05 23:35", "fromWho": "hello1@email.se" }, { "id": "2", "msg": "there", "tid": "2013-05-05 23:45", "fromWho": "hello2@email.se" } และได้ลองทำดังนี้ for (var key in data) { if (data.hasOwnProperty(key)) { console.log(data[key].id); } } แต่ด้วยเหตุผลบางอย่างที่ฉันได้รับเฉพาะส่วนแรกค่า id 1 เท่านั้น ความคิดใด ๆ
151
javascript
json