如何获取座位对象中json数组中的最后一个元素。我想获得值为845的countryid,但是这个json是动态的,所以我想获得座位对象中的最后一个元素。我的API是这样构造的。先谢谢你。获取json数组中的最后一个元素
{
"expirationDate":"April 21, 2017",
"remainingDays":325,
"seats":[{"activeStatus":"S","pid":"TE70","firstName":"TE70","countryid":840},
{"activeStatus":"Y","pid":"TE80","firstName":"TE80","countryid":845}]
}
你是否尝试过使用'length - 1'进行索引? –
是的,我试过了,但我无法弄清楚。感谢您的答复。 –