首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何仅当JOLT中的字段不为空时进行映射

如何仅当JOLT中的字段不为空时进行映射
EN

Stack Overflow用户
提问于 2018-07-31 17:28:07
回答 2查看 985关注 0票数 0

以下是我的输入:

代码语言:javascript
复制
   { "isPoolPoint": "test", "timeZone": "ET" }

我希望输出为:

代码语言:javascript
复制
   { "address" : [{"line2": "test"}] }

如果isPoolPoint是一个null,我不应该得到任何东西作为输出。

EN

回答 2

Stack Overflow用户

发布于 2018-08-03 04:01:59

等级库

代码语言:javascript
复制
[
  {
    "operation": "shift",
    "spec": {
      "isPoolPoint": {
        // match down into the values of "isPoolPoint"
        // if we match null, then do nothing
        "null": null,
        // match everything else
        "*": {
          // write what was matched to the output
          "$": "address[0].line2"
        }
      }
    }
  }
]
票数 2
EN

Stack Overflow用户

发布于 2021-08-06 10:18:48

代码语言:javascript
复制
I wanted to ignore blank strings as well in addition to null values so I did below extra condition

[
  {
    "operation": "shift",
    "spec": {
      "isPoolPoint": {
         // OR operator below will care of empty string or null
        "|null": null,
        "*": {
          "$": "address[0].line2"
        }
      }
    }
  }
]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51609993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档