如何使用 'modify-overwrite-beta' 在 jolt 中执行除法运算
How to perform divide operation in jolt using 'modify-overwrite-beta'
输入,
{"scores": [ 4,2,8,7,5 ] }
输出,
{"FirstElement": 2 } //This is generated by dividing the first element of the array by 2.
规格,
[{
"operation": "modify-overwrite-beta",
"spec": {
"Avg": "=divide(=firstElement(@(1,scores)),2)"
}
}]
根据上面的规范,我试图将列表的第一个元素除以 2,但我得到的输出与输入相同。
不能用修改嵌套 "functions"。必须把它分成两步。
[
{
"operation": "modify-overwrite-beta",
"spec": {
"firstElement": "=firstElement(@(1,scores))"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"Avg": "=divide(@(1,firstElement),2)"
}
}
]
输入,
{"scores": [ 4,2,8,7,5 ] }
输出,
{"FirstElement": 2 } //This is generated by dividing the first element of the array by 2.
规格,
[{
"operation": "modify-overwrite-beta",
"spec": {
"Avg": "=divide(=firstElement(@(1,scores)),2)"
}
}]
根据上面的规范,我试图将列表的第一个元素除以 2,但我得到的输出与输入相同。
不能用修改嵌套 "functions"。必须把它分成两步。
[
{
"operation": "modify-overwrite-beta",
"spec": {
"firstElement": "=firstElement(@(1,scores))"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"Avg": "=divide(@(1,firstElement),2)"
}
}
]