【发布时间】:2021-07-23 18:46:03
【问题描述】:
我有 2 个变量,分别称为“score”和“scoreRange”,假设“score”值为 0.185,我想将其与 0.3 和 0.9 进行比较。我的情况如下。
if score is less than 0.3 (score <0.3) -> mark scoreRange as LOW,
0.3 to 0.9 (0.3 <= score < 0.9) --> mark scoreRange as MEDIUM
and larger than 0.9 (score >= 0.9) --> mark scoreRaneg as HIGH
如何比较 0.185 与 0.3 或 0.9 的颠簸。 我尝试创建一个值为 [0.3, 0.9] 的数组,并将“分数”添加到该数组“数组”:[0.3、0.9、0.185]。然后取出该数组的最小值和最大值。如果 Score 位于 min 位置或等于 min 则 scoreRange 为低。如果 Score 处于最大位置或等于 max,则 scoreRange 为高。如果两者都失败则中等。但目前我不知道如何与正常值或数组值进行比较。
我的输入(无关)
{
"sampleArray": [
4,
2,
8
]
}
试用规格
[
{
"operation": "default",
"spec": {
"array": [0.3, 0.9]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"score": 0.185,
"array": {
"[2]": "@(2,sumIntData)"
},
"minAB": "=min(@(1,array))",
"maxAB": "=max(@(1,array))"
}
}
]
我当前的输出。
{
"sampleArray" : [ 4, 2, 8 ],
"array" : [ 0.3, 0.9, 0.185 ],
"score" : 0.185,
"minAB" : 0.185,
"maxAB" : 0.8
}
我是新手。比较值的任何指导都会对我有所帮助。 以及如何从 jolt 中的数组中获取特定值。 jolt 的 elementAt 选项没有帮助
【问题讨论】: