如何编写JOLT Shift转换规则实现JSON列表到指定actions结构的转换
适配需求的JOLT转换规范
以下JOLT规则可直接实现你要求的输入输出转换,已经包含了数值类型转字符串的逻辑,匹配你期望输出中number字段值为字符串的要求:
[ { "operation": "shift", "spec": { "#SetFieldValue": "actions[0]._type", "#UUID": "actions[0].fieldName", "#uuid": "actions[0].value", "*": { "#InsertRow": "actions[&1]._type", "number": { "#SetFieldValue": "actions[&2].number._type", "#number": "actions[&2].number.fieldName", "@": "actions[&2].number.value" }, "description": { "#SetFieldValue": "actions[&2].description._type", "#description": "actions[&2].description.fieldName", "@": "actions[&2].description.value" } }, "#SetFieldValue": "actions[#]._type", "#start": "actions[#].fieldName" } }, { "operation": "shift", "spec": { "actions": { "*": { "@": "actions[]", "*": "actions[]" } } } }, { "operation": "modify-overwrite-beta", "spec": { "actions": { "*": { "value": ["toString", "@(1,value)"] } } } } ]
内容的提问来源于stack exchange,提问作者franz bauer
相关产品推荐
相关产品推荐

