如何以格式访问JSON数据:获取id et.al等JSON数据
[
{
id: 10,
hotelName: "TajBanjara",
pricePerNight: 200.23,
nbOfNights: 3,
totalPrice: 600.6899999999999
},
{
id: 11,
hotelName: "TajKrishna",
pricePerNight: 90.23,
nbOfNights: 2,
totalPrice: 180.46
},
{
id: 12,
hotelName: "Novatel",
pricePerNight: 100.23,
nbOfNights: 3,
totalPrice: 300.69
}
]
答案 0 :(得分:0)
var data = [{id:10,hotelName:“TajBanjara”,pricePerNight:200.23, nbOfNights:3,totalPrice:600.6899999999999},{id:11,hotelName: “TajKrishna”,pricePerNight:90.23,nbOfNights:2,totalPrice:180.46 },{id:12,hotelName:“Novatel”,pricePerNight:100.23,nbOfNights: 3,totalPrice:300.69}]
你可以获得id值
对于json数组中的第一个对象, data[0].id
。