我的输入如下所示,如果timeMeasurementUnitCode="DAY"
,则值需要计算为value*24*60
,如果timeMeasurementUnitCode="HOUR"
,则值为value*60
我发现人们正在寻找一个类似的用例the ticket is opened on Jul 17, 2019
:https://github.com/bazaarvoice/jolt/issues/832
问题832现在似乎仍处于打开状态
输入:
{
"freightCharacteristics": {
"transitDuration": {
"timeMeasurementUnitCode": "DAY",
"value": 6
},
"loadingDuration": {
"timeMeasurementUnitCode": "HOUR",
"value": 6
}
}
}
预期产出:根据输入中提供的常量DAY
或HOUR
,我需要乘以no.of days*hours*minutes
才能达到如下所示的要求。
{
"transitDurationInMinutes" : 8640,
"loadingDurationInMinutes" : 360
}
]
根据@mattyb的建议,我使用了除法函数来实现乘法所要实现的功能,逻辑更新如下。
[
{
"operation": "shift",
"spec": {
"freightCharacteristics": {
"transitDuration": {
"timeMeasurementUnitCode": {
"DAY": {
"@(2,value)": "transitDurationInMinutes"
},
"*": {
"@(2,value)": "transitDurationInMinutes"
}
}
},
"loadingDuration": {
"timeMeasurementUnitCode": {
"HOUR": {
"@(2,value)": "loadingDurationInMinutes"
},
"*": {
"@(2,value)": "loadingDurationInMinutes"
}
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"transitDurationInMinutes": "=divide(@(1,transitDurationInMinutes),0.00069444444)",
"loadingDurationInMinutes": "=divide(@(1,loadingDurationInMinutes),0.01666666666)"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"transitDurationInMinutes": "=toInteger",
"loadingDurationInMinutes": "=toInteger"
}
}
]
1条答案
按热度按时间46qrfjad1#
另一个选项是分别使
DAY
和HOUR
文字对象键,以便在下一步中有条件地选取它们,例如http://jolt-demo.appspot.com/站点上的***演示***是