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

如何在NiFi中使用Jolt Spec实现指定规则的数据转换

NiFi Jolt 数据转换需求与示例

转换规则

  • 当studentId与loc_id的值同时匹配时,合并对应条目,将重复条目中的topId、SubID1、SubID2字段存入新增的VisitList数组
  • 不满足合并条件的条目保持原样,同样新增VisitList字段存储原条目内的topId、SubID1、SubID2信息
  • 保留值为""的空字段

原始数据

[
  {
    "studentId": "2222",
    "loc_id": "L1",
    "topId": "Lotus",
    "SubID1": "A1",
    "SubID2": "B1"
  },
  {
    "studentId": "2222",
    "loc_id": "L1",
    "topId": "tulip",
    "SubID1": "A2",
    "SubID2": ""
  },
  {
    "studentId": "3333",
    "loc_id": "L3",
    "topId": "Rose",
    "SubID1": "A3",
    "SubID2": ""
  },
  {
    "studentId": "4444",
    "loc_id": "L3",
    "topId": "Rose",
    "SubID1": "A5",
    "SubID2": "B7"
  }
]

Jolt转换后目标数据

[
  {
    "studentId": "2222",
    "loc_id": "L1",
    "VisitList": [
      {
        "topId": "Lotus",
        "SubID1": "A1",
        "SubID2": "B1"
      },
      {
        "topId": "tulip",
        "SubID1": "A2",
        "SubID2": ""
      }
    ]
  },
  {
    "studentId": "3333",
    "loc_id": "L1",
    "VisitList": [
      {
        "topId": "Rose",
        "SubID1": "A3",
        "SubID2": ""
      }
    ]
  },
  {
    "providerId": "4444",
    "specillity": "L3",
    "VisitList": [
      {
        "topId": "Rose",
        "SubID1": "A5",
        "SubID2": "B7"
      }
    ]
  }
]

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 15:30:20