You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何编写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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 17:54:02