我有这样的 JSON 数据:
{
"output_type": "json",
"round_trip": false,
"search_queries": {
"from": "AMQ",
"to": "CGK",
"date": "2013-01-03",
"ret_date": "",
"adult": 1,
"child": 0,
"infant": 0
},
"go_det": {
"dep_airport": {
"airport_code": "AMQ",
"international": "0",
"trans_name_id": "7564",
"business_name": "PATTIMURA",
"business_name_trans_id": "5923",
"business_id": "20349",
"country_name": "Indonesia ",
"city_name": "Ambon",
"province_name": "Maluku",
"location_name": "Ambon"
},
"arr_airport": {
"airport_code": "CGK",
"international": "1",
"trans_name_id": "7574",
"business_name": "Soekarno-Hatta",
"business_name_trans_id": "5935",
"business_id": "20361",
"country_name": "Indonesia ",
"city_name": "Jakarta Barat",
"province_name": "DKI Jakarta",
"location_name": "Jakarta"
},
"date": "2013-01-03",
"formatted_date": "03 Januari 2013"
},
"diagnostic": {
"status": 200,
"elapsetime": "1.9305",
"memoryusage": "12.14MB",
"confirm": "success",
"lang": "id",
"currency": "IDR"
},
"departures": {
"result": [
{
"flight_id": "605783",
"airlines_name": "BATAVIA",
"flight_number": "Y6-852",
"price_value": "1566900.00",
"timestamp": "2012-10-25 08:51:48",
"price_adult": "1566900.00",
"price_child": "0.00",
"price_infant": "0.00",
"simple_departure_time": "06:55",
"simple_arrival_time": "08:10",
"stop": "Langsung",
"long_via": "",
"duration": "3 j 15 m",
"image": "https://www.master18.tiket.com/images/icon_batavia.jpg"
},
{
"flight_id": "605786",
"airlines_name": "LION",
"flight_number": "JT-1791",
"price_value": "1391000.00",
"timestamp": "2012-10-25 08:51:42",
"price_adult": "1391000.00",
"price_child": "0.00",
"price_infant": "0.00",
"simple_departure_time": "08:00",
"simple_arrival_time": "10:35",
"stop": "1 Transit",
"long_via": "",
"duration": "4 j 35 m",
"image": "https://www.master18.tiket.com/images/icon_lion.jpg"
}
]
},
}
我尝试过像这里这样的举动:
但是还没有找到结果。
我之前的代码是这样的:
var success = function(response) {
for ( var i = 0; i < response.go_det.length; ++i ) {
strKotaAwal = response[i].go_det.dep_airport.airport_code;
strKotaTujuan = response[i].go_det.arr_airport.airport_code;
};
我想提取另一个数据,例如:
[flight_id] => 605783
[airlines_name] => BATAVIA
[flight_number] => Y6-852
[price_value] => 1566900.00
[simple_departure_time] => 06:55
[simple_arrival_time] => 08:10
[duration] => 3 j 15 m
[image] => https://www.master18.tiket.com/images/icon_batavia.jpg