在一个SON中,我有一个带有指标值的绳子长度,我的任务是生成具有英制输出的"双胞胎".根据"公制"输入中指定的单位(uom),应计算英制值.键中"单位-"后面的值始终是可变的.
这是我的输入Python
{
"unit-1012108-unitNo": "1012108",
"unit-1012108-description": "IGNITE PROTON WIND",
"unit-1012108-category": "211",
"unit-1012108-att-rope_length-identifier": "rope_length",
"unit-1012108-att-rope_length-type": "attribute",
"unit-1012108-att-rope_length-attributeDataType": "DECIMAL",
"unit-1012108-att-rope_length-values-0-value": "5.21",
"unit-1012108-att-rope_length-values-0-uom": "cm"
}
这是我想要的输出杨森.稍后可以删除两个辅助字段"-calc-". 我的规格的任务应该是计算2.03英寸.
{
"unit-1012108-att-rope_length-identifier" : "rope_length",
"unit-1012108-att-rope_length-type" : "attribute",
"unit-1012108-att-rope_length-values-0-uom" : "cm",
"unit-1012108-att-rope_length-values-0-value" : "5.21",
"unit-1012108-att-rope_length_imp-identifier" : "rope_length_imp",
"unit-1012108-att-rope_length_imp-type" : "attribute",
"unit-1012108-att-rope_length_imp-values_0-uom" : "inch",
"unit-1012108-att-rope_length_imp-values_0-value" : "2.03",
"unit-1012108-rope_length-calc_imp" : "0.39",
"unit-1012108-rope_length_calc_metric" : "5.21"
}
我被规格困住了.我的问题就在这里.如何将"Unit--rope_length-calc_imp"与"Unit--rope_long_calc_metric"相乘,然后将值赋给"Unit-*-att-rope_long_imp-values_0-values"?这就是我到目前为止的进展:
[
{
"operation": "shift",
"spec": {
"unit-*-att-rope_length-values-0-value": [
"&",
"unit-&(0,1)-att-rope_length_imp-values_0-value",
"unit-&(0,1)-rope_length_calc_metric"
],
"unit-*-att-rope_length-values-0-uom": [
"&",
"unit-&(0,1)-att-rope_length_imp-values_0-uom"
],
"unit-*-att-rope_length-identifier": [
"&",
"unit-&(0,1)-att-rope_length_imp-identifier"
],
"unit-*-att-rope_length-type": [
"&",
"unit-&(0,1)-att-rope_length_imp-type"
]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"unit-*-att-rope_length_imp-identifier": "=concat(rope_length,'_imp')"
}
},
{
"operation": "shift",
"spec": {
"unit-*-att-rope_length_imp-values_0-uom": {
"m": {
"#feet": "&2",
"#3.28": "unit-&(2,1)-rope_length-calc_imp"
},
"cm": {
"#inch": "&2",
"#0.39": "unit-&(2,1)-rope_length-calc_imp"
},
"mm": {
"#inch": "&2",
"#0.04": "unit-&(2,1)-rope_length-calc_imp"
},
"*": {
"@(2,&1)": "&2"
}
},
"*": "&"
}
},
{
"operation": "sort"
}
]
任何暗示都将不胜感激.