基于字段的颠簸条件

问题描述 投票:0回答:1

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

输入:

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

输出:

如果存在c字段,则输出应为

{
  "b" : "cValue"
}

如果c字段不存在,则输出应为

{
  "a" : "aValue",
  "b" : "bValue
}
json transformation jolt
1个回答
0
投票

尝试此

[
  {
    "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"
        }
      }
    }
  }
]
© www.soinside.com 2019 - 2024. All rights reserved.