我一直在尝试通过以下 JSON 数据和 console.log 解析特定值的 stop_ids。因此,当我选择停止 ID“L26S”时,控制台将记录每个停止时间发生在 JSON 中的实例。我想要的停止时间在 trip_update.stop_time_update.arrival.time.low
我尝试使用以下方法失败(提要是我的 JSON 文件的名称),我相信我在正确的道路上,但我不知道如何继续。任何帮助,将不胜感激。
var feed = {
"entity": [{
"id": "1",
"is_deleted": false,
"trip_update": {
"trip": {
"trip_id": "009250_L..S",
"route_id": "L",
"start_time": null,
"start_date": "20170512",
"schedule_relationship": null,
".nyct_trip_descriptor": {
"train_id": "0L 0132+8AV/RPY",
"is_assigned": true,
"direction": 3
}
},
"vehicle": null,
"stop_time_update": [{
"stop_sequence": null,
"stop_id": "L26S",
"arrival": {
"delay": null,
"time": {
"low": 1494569453,
"high": 0,
"unsigned": false
},
"uncertainty": null
},
"departure": {
"delay": null,
"time": {
"low": 1494569483,
"high": 0,
"unsigned": false
},
"uncertainty": null
},
"schedule_relationship": 0,
".nyct_stop_time_update": {
"scheduled_track": "1",
"actual_track": "1"
}
},
{
"stop_sequence": null,
"stop_id": "L27S",
"arrival": {
"delay": null,
"time": {
"low": 1494569551,
"high": 0,
"unsigned": false
},
"uncertainty": null
}
}
]
}
}]
}
$.each(feed.entity[0].trip_update.stop_time_update[1], function(i, v) {
if (v.stop_id == "L02N") {
console.log(v.arrival.time.low);
return;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>