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

如何编写Jolt规范将指定JSON节点字段提取为subscriberIds数组?

Jolt 转换实现方案

实现逻辑

按照需求需按顺序提取两个值存入subscriberIds数组:

  1. 取origin节点下的accountId作为数组第一个元素
  2. 仅当origin.group.type值为LE时,取origin.group.referenceId作为数组第二个元素

完整Jolt Specification

[
  {
    "operation": "shift",
    "spec": {
      "origin": {
        "accountId": "subscriberIds[0]",
        "group": {
          "type": {
            "LE": {
              "@(2,referenceId)": "subscriberIds[1]"
            }
          }
        }
      }
    }
  }
]

转换效果验证

输入样例

{
  "origin": {
    "site": "XXXXXX",
    "service": "XXXXXXXX",
    "accountId": "1001472060",
    "transactionId": "112477870",
    "group": {
      "type": "LE",
      "referenceId": "2141"
    }
  }
}

输出结果

{
  "subscriberIds": ["1001472060", "2141"]
}

说明

  • 若origin.group.type的值不是LE,输出的subscriberIds数组仅会保留accountId一个元素,符合过滤规则
  • 数组顺序严格遵循需求:accountId在前,LE类型的referenceId在后

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 21:27:00