Exception 响应SLURPER错误groovy
我在尝试将这句话封装到groovy函数中时遇到了问题 ------------------------------------mi呼叫---------------------- -------------------------------我的功能----------------------Exception 响应SLURPER错误groovy,exception,groovy,Exception,Groovy,我在尝试将这句话封装到groovy函数中时遇到了问题 ------------------------------------mi呼叫---------------------- -------------------------------我的功能---------------------- def getTotalPrice (sizeOfferPrices){ def strTravelersAssociated def floatImporteViaje = 0
def getTotalPrice (sizeOfferPrices){
def strTravelersAssociated
def floatImporteViaje = 0
String [] arrTravelersAssociated
def offerAmountTemp
//recorremos los precios que se nos ha devuelto en la oferta
for(i=0; i<=sizeOfferPrices-1; i++){
//obtenemos el precio
offerAmountTemp = responseAsSlurper.Body.FlightPriceRS.PricedFlightOffers.PricedFlightOffer.OfferPrice[i].RequestedDate.PriceDetail.TotalAmount.SimpleCurrencyPrice
offerAmountTemp = offerAmountTemp.toFloat();
//obtenemos los datos de los viajeros asociados , casteamos a string y splitamos para obtener array
strTravelersAssociated = responseAsSlurper.Body.FlightPriceRS.PricedFlightOffers.PricedFlightOffer.OfferPrice[i].RequestedDate.Associations.AssociatedTraveler.TravelerReferences
strTravelersAssociated = strTravelersAssociated.toString();
arrTravelersAssociated = strTravelersAssociated.tokenize(" ");
//obtenemos el numero de viajeros por oferta
intTravelersByOffer = arrTravelersAssociated.size().toInteger();
//realizamos la multiplicaciónd viajeros por su oferta asociada
floatImporteViajeTemp = (offerAmountTemp * intTravelersByOffer).round(2);
floatImporteViaje = floatImporteViaje + floatImporteViajeTemp;
}
//obtenemos el precio total
amount = floatImporteViaje.round(2);
return amount
}
def getTotalPrice(sizeOfferPrices){
def STRTRAVELERS关联
def floatImporteViaje=0
关联的字符串[]arrTravelersAssociated
def OFFRAMOUNTTEMP
//在奥弗塔的酒店里,您可以享受到最优质的服务
对于(i=0;i,错误与您发布的函数无关,因为它发生在调用函数之前
sizeOfferPrices = responseAsSlurper.Body.FlightPriceRS.PricedFlightOffers.PricedFlightOffer.OfferPrice.size();
offerAmount = getTotalPrice(sizeOfferPrices)
错误发生在第一行(在调用getTotalPrice
之前),因为您试图访问一个不存在的属性responseAsSlurper
。欢迎使用堆栈溢出。您当前的问题可能会被关闭。请阅读。
sizeOfferPrices = responseAsSlurper.Body.FlightPriceRS.PricedFlightOffers.PricedFlightOffer.OfferPrice.size();
offerAmount = getTotalPrice(sizeOfferPrices)