У меня есть JSON-файл, который выглядит следующим образом:
Из этого JSON мне нужно получить только общую цену за каждый рейс.И мне нужно получить количество рейсов в один конец (размер списка сегментов).Я создал так много объектов, используя http://www.jsonschema2pojo.org/. И с большим количеством циклов for я получаю необходимые данные.Но мой вопрос: есть ли более простой способ получить эту информацию из этого файла JSON?
{
"type": "flight-offer",
"id": "1549454712606-1539032420",
"offerItems": [
{
"services": [
{
"segments": [
{
"flightSegment": {
"departure": {
"iataCode": "SJJ",
"at": "2019-02-08T06:30:00+01:00"
},
"arrival": {
"iataCode": "ZAG",
"at": "2019-02-08T07:20:00+01:00"
},
"carrierCode": "OU",
"number": "341",
"aircraft": {
"code": "DH4"
},
"operating": {
"carrierCode": "OU",
"number": "341"
},
"duration": "0DT0H50M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "K",
"availability": 3,
"fareBasis": "KEASY2"
}
}
]
},
{
"segments": [
{
"flightSegment": {
"departure": {
"iataCode": "ZAG",
"at": "2019-02-15T14:10:00+01:00"
},
"arrival": {
"iataCode": "SJJ",
"at": "2019-02-15T15:00:00+01:00"
},
"carrierCode": "OU",
"number": "344",
"aircraft": {
"code": "DH4"
},
"operating": {
"carrierCode": "OU",
"number": "344"
},
"duration": "0DT0H50M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "U",
"availability": 9,
"fareBasis": "UEASY2"
}
}
]
}
],
"price": {
"total": "164.09",
"totalTaxes": "83.09"
},
"pricePerAdult": {
"total": "164.09",
"totalTaxes": "83.09"
}
}
]
},
{
"type": "flight-offer",
"id": "1549454712606--1458421402",
"offerItems": [
{
"services": [
{
"segments": [
{
"flightSegment": {
"departure": {
"iataCode": "SJJ",
"at": "2019-02-08T15:10:00+01:00"
},
"arrival": {
"iataCode": "BEG",
"terminal": "2",
"at": "2019-02-08T16:00:00+01:00"
},
"carrierCode": "JU",
"number": "113",
"aircraft": {
"code": "AT7"
},
"operating": {
"carrierCode": "JU",
"number": "113"
},
"duration": "0DT0H50M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "U",
"availability": 7,
"fareBasis": "UNBRBA"
}
},
{
"flightSegment": {
"departure": {
"iataCode": "BEG",
"terminal": "2",
"at": "2019-02-08T18:20:00+01:00"
},
"arrival": {
"iataCode": "ZAG",
"at": "2019-02-08T19:35:00+01:00"
},
"carrierCode": "JU",
"number": "234",
"aircraft": {
"code": "AT7"
},
"operating": {
"carrierCode": "JU",
"number": "234"
},
"duration": "0DT1H15M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "U",
"availability": 7,
"fareBasis": "UNBRBA"
}
}
]
},
{
"segments": [
{
"flightSegment": {
"departure": {
"iataCode": "ZAG",
"at": "2019-02-15T10:00:00+01:00"
},
"arrival": {
"iataCode": "BEG",
"terminal": "2",
"at": "2019-02-15T11:05:00+01:00"
},
"carrierCode": "JU",
"number": "231",
"aircraft": {
"code": "AT7"
},
"operating": {
"carrierCode": "JU",
"number": "231"
},
"duration": "0DT1H5M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "U",
"availability": 7,
"fareBasis": "UNBRBA"
}
},
{
"flightSegment": {
"departure": {
"iataCode": "BEG",
"terminal": "2",
"at": "2019-02-15T13:50:00+01:00"
},
"arrival": {
"iataCode": "SJJ",
"at": "2019-02-15T14:40:00+01:00"
},
"carrierCode": "JU",
"number": "112",
"aircraft": {
"code": "AT7"
},
"operating": {
"carrierCode": "JU",
"number": "112"
},
"duration": "0DT0H50M"
},
"pricingDetailPerAdult": {
"travelClass": "ECONOMY",
"fareClass": "U",
"availability": 7,
"fareBasis": "UNBRBA"
}
}
]
}
],
"price": {
"total": "225.45",
"totalTaxes": "145.45"
},
"pricePerAdult": {
"total": "225.45",
"totalTaxes": "145.45"
}
}
]
}