我有下面的Payload。这里,如果点数不能被5整除,则向上舍入到最接近的5。因此,如果点数为250.2,则结果数字将为250,并且可以被5整除,因此返回的值将为250。如果结果值为251.2,则结果整数将是251,并且不能被5整除,将被上舍入为155
{
"referenceID": "1001",
"Year": "2023",
"Type": "BK",
"contracts": [
{
"contractId": "1",
"contractType": "Booking",
"Points": "250.2",
"Reservations": {
"reservations": [
],
"reservationPoints": ""
}
},
{
"contractId": "1",
"contractType": "Booking",
"Points": "251.2",
"Reservations": {
"reservations": [
],
"reservationPoints": ""
}
}
]
}
基于上述条件,输出有效载荷应如下所示
{
"referenceID": "1001",
"Year": "2023",
"Type": "BK",
"contracts": [
{
"contractId": "1",
"contractType": "Booking",
"Points": "250",
"Reservations": {
"reservations": [
],
"reservationPoints": ""
}
},
{
"contractId": "1",
"contractType": "Booking",
"Points": "255",
"Reservations": {
"reservations": [
],
"reservationPoints": ""
}
}
]
}
关于此四舍五入点到最近的数字可被5整除,我使用以下逻辑
if (((payload.contracts[0].Points as Number mod 5))<1)
(round((payload.contracts[0].Points as Number)/5)*5)
else
(ceil((payload.contracts[0].Points as Number)/5)*5)
这将根据条件获得更新的值,但我无法更新有效负载。
2条答案
按热度按时间o4tp2gmn1#
使用更新操作符仅更新有效负载对象中的点值。尝试如下:
quhf5bfb2#
基于以上建议,我更新了如下的有效载荷