Hi All,
I need to create query to fetch below fields out of nested json. whats the best way to achieve the same. we are able querying json at depth of level using unnest function.We have to query 2-3 level of json.
Below are fields to be fetched in query
select itnryBook.hotelReservations.hotelReservation.hotelSegment.checkInDate.localTime,
paymentSummary.payment.cardPayment.billingAddress from “bucket” where conditon=?
{
"MTR": {
"itnryBook": {
"hotelReservations": {
"hotelReservation": [
{
"hotelSegment": [
{
"checkInDate": {
"localTime": "2018-11-07"
},
"checkOutDate": {
"localTime": "2018-11-08"
},
"confirmationNumber": "PSZBA2",
"hotel": {
"brandCd": "Extended Stay America",
"chainCd": "840",
"contactInfo": {
"callInInfo": {},
"mailingInfo": {
"address": [
{
"addressLine1": "3421 East Elwood St",
"addressLine2": "3421 East Elwood St",
"cityName": "Phoenix",
"coordinates": {
"latitude": "0.0",
"longitude": "0.0"
},
"countryCd": "US",
"stateProvinceCd": "AZ",
"zipCd": "85040"
}
]
}
},
"name": "Extended Stay America - Phoenix - Airport",
"policies": {
"cancellationPolicy": [
"This reservation is non-refundable. Cancellations or changes made at any time are subject to a 100% charge."
]
},
"propertyNumber": 9716,
"starRating": "3"
},
"pricing": {
"payment": {
"payment": [
{
"paymentID": [
"01"
]
}
]
},
"roomPrice": {
"dailyRateBreakdown": [
{
"baseFare": {
"supplierFare": {
"amount": 71.99,
"currency": "USD"
},
"systemFare": {
"amount": 71.99,
"currency": "USD"
}
},
"noofNights": 1,
"totalFare": {
"supplierFare": {
"amount": 71.99,
"currency": "USD"
},
"systemFare": {
"amount": 71.99,
"currency": "USD"
}
}
}
]
},
"tax": {
"supplierFare": {
"amount": 9.06,
"currency": "USD"
},
"systemFare": {
"amount": 9.06,
"currency": "USD"
}
},
"totalPrice": {
"supplierFare": {
"amount": 81.05,
"currency": "USD"
},
"systemFare": {
"amount": 81.05,
"currency": "USD"
}
}
},
"room": {
"guest": {
"paxRPH": [
{
"value": "00.01"
}
]
},
"guestCount": "0",
"maxPersons": "0",
"primaryPaxRPH": "00.01",
"roomType": {
"code": "206288",
"description": "Studio, 1 Queen Bed, Non Smoking - 1 queen bed"
}
},
"salesModel": "Pay Now",
"status": "Success"
}
],
"identifier": {
"inventorySystem": "Orbitz",
"inventorySystemType": "OTA",
"recordLocator": "PBAXP6211403644"
},
"programs": {
"program": [
""
]
},
"reservationRPH": "${trip1}-${trip2}-01",
"total": {
"systemFare": {
"amount": 81.05,
"currency": "USD"
}
},
"transactionTime": {
"createTime": {
"systemTime": "2018-09-11"
},
"lastUpdatedTime": {
"systemTime": "2018-09-11 13:43:05.0"
}
}
}
]
},
"paymentSummary": {
"payment": [
{
"cardPayment": {
"card": {
"billingAddress": {
"addressLine1": "2313 EAST DRYWOOD ROAD",
"cityName": "PHOENIX",
"country": "US",
"countryCd": "US",
"stateProvince": "AZ",
"stateProvinceCd": "AZ",
"zipCd": "850248688"
},
},
"creditAmount": {
"systemFare": {
"amount": 81.05,
"currency": "USD"
}
}
},
"paymentAmount": {
"systemFare": {
"amount": 81.05,
"currency": "USD"
}
},
"paymentID": "01",
"paymentType": "CREDIT_CARD"
}
]
}
}
}
"type": "test"
}