【问题标题】:Jolt Conditional Based on Field基于字段的 Jolt 条件
【发布时间】:2020-04-20 06:56:06
【问题描述】:

我想对字段进行条件检查。是否有任何运算符可以让我们对 JOLT 中的字段进行条件检查?

输入:

{
  "a" : "aValue",
  "b" : "bValue,
  "c" : "cValue"
}

输出:

如果c字段存在,输出应该是

{
  "b" : "cValue"
}

如果c字段不存在,输出应该是

{
  "a" : "aValue",
  "b" : "bValue
}

【问题讨论】:

    标签: json transformation jolt


    【解决方案1】:

    试试这个

    [
      {
        "operation": "modify-default-beta",
        "spec": {
          // If c does not exists add the c with default value as null
          "c": "null"
        }
      },
      {
        "operation": "shift",
        "spec": {
          "b": "b",
          "c": {
            "null": {
              "@(2,a)": "a"
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-21
      • 2011-08-27
      • 2023-04-09
      • 2012-12-08
      • 2010-11-23
      • 2015-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多