我有像
{
"itinerary": {
"carrier": "9W",
"refundable": false,
"dept": {
"flightList": [
{
"from": {
"date": "200713",
"code": "KTM",
"terminal": null,
"time": "1430"
}
},
{
"from": {
"date": "210713",
"code": "BOM",
"terminal": "1B",
"time": "0440"
}
},
{
"from": {
"date": "210713",
"code": "AMD",
"terminal": null,
"time": "1420"
}
}
]
}
}
现在我想从 json 中显示“KTM”和“AMD”,这是 itinerary.dept.flightList 的第一个和最后一个数组现在我可以得到像这样的第一个索引 {itinerary.dept.flightList[0].from.code} 但是我不能得到最后一个。谁能帮我在不使用循环的情况下获取 itinerary.dept.flightList 的最后一个索引