如何使用angularJs 1.6获取格式低于格式的json数据

时间:2018-01-09 09:34:42

标签: arrays angularjs json

如何以格式访问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
    }
    ]

1 个答案:

答案 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