JOLT 操作根据字符串数组中给出的键过滤结构

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

我有这个 JSON 输入:

{
 "input":{
   "a":"valueA",
   "b":"valueB",
   "c":"valueC"
  },
 "fieldsToFilterBy":["a","c"]
}

我想要这个输出:

{
 "input":{
   "a":"valueA",
   "b":"valueB",
   "c":"valueC"
  },
 "filteredValues":["valueA","valueC"]
}

如何使用 JOLT 操作获取此信息?我尝试了很多方法,但没有一个完全有效

json apache-nifi jolt operation
1个回答
0
投票

您可以尝试以下规格:

[
  {
    "operation": "shift",
    "spec": {
      "*": "&",
      "fieldsToFilterBy": {
        "*": "input.@(0)"
      }
    }
  }
  ,
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "0": {
            "@": ["&3.&2", "filteredValues[]"]
          },
          "1": {
            "": ""
          },
          "*": {
            "$": "&3.&2"
          }
        }
      }
    }
  }

]
© www.soinside.com 2019 - 2024. All rights reserved.