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

求助JOLT转换:仅提取MySQL Binlog数据中columns的id字段

JOLT 提取 MySQL Binlog 中指定列的值

输入示例(典型 MySQL Binlog JSON 结构)

{
  "table": "users",
  "columns": [
    {
      "name": "id",
      "value": 1001
    },
    {
      "name": "username",
      "value": "john_doe"
    },
    {
      "name": "email",
      "value": "john@example.com"
    }
  ]
}

目标输出

{
  "id": 1001
}

修正后的 JOLT Shift 规则

[
  {
    "operation": "shift",
    "spec": {
      "columns": {
        "*": {
          "name": {
            "id": {
              "@(2,value)": "id"
            }
          }
        }
      }
    }
  }
]

规则说明

  • columns.* 遍历 columns 数组的每一个元素
  • 针对每个元素的 name 字段,仅匹配值为 id 的项
  • @(2,value) 是相对路径定位:从当前匹配的 id 节点向上回溯2层(回到数组元素节点),提取该节点下的 value 值,最终映射到输出的 id 键

如果你的Binlog结构中,字段值不是存在value字段(比如是new_value或其他),只需要把@(2,value)里的value替换成对应的字段名即可。

内容的提问来源于stack exchange,提问作者santhosh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 19:25:01