首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更新Apache-Nifi中的Json-属性

更新Apache-Nifi中的Json-属性
EN

Stack Overflow用户
提问于 2017-09-21 08:59:21
回答 1查看 1.3K关注 0票数 1

我是Apache的新手,有以下问题:我想转换一个json文件,如下所示:

代码语言:javascript
复制
{
    "Property1": "x1",
    "Property2": "Tag_**2ABC**",
    "Property3": "x3",
    "Property4": "x4"
    }

至:

代码语言:javascript
复制
{
    "**2ABC**_Property1": "x1",
    "**2ABC**_Property3": "x3",
    "**2ABC**_Property4": "x4"
    },

它的意思是:从某个属性中获取值来更新所有其他属性。当更新只添加一个字符串时,我可以找到使用JoltTransformer的示例,这些示例运行良好。但就我的情况而言,到目前为止我所做的并不是这样:我使用evaluateJSONPath处理器设置了每个属性。但我只是尝试了很多使用update属性处理器的可能性,但都没有成功。我所有可能的测试都类似于(在UpdateAttribute中):

代码语言:javascript
复制
Property1 --> ${'Property2':substring(4,6)}"_"${'Property1'}

使用震动:

代码语言:javascript
复制
[
{"operation": "modify-overwrite-beta",
    "spec": {
        "Property1": "${'Property2':substring(4,6)}_${'Property1'}"
            }
}
]

我在这漏掉了什么?提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-21 23:39:00

我不知道Nifi,但这是你如何在颠簸中做到的。

等级库

代码语言:javascript
复制
[
  {
    "operation": "shift",
    "spec": {
      // match Property2
      "Property2": {
        "Tag_*": { // capture the nasty "**2ABC**" part to reference later
          // go back up the tree to the root
          "@2": {
            // match and ignore Property2
            "Property2": null,
            //
            // match Property* and use it and the captured 
            //  "prefix" to create the output key
            //  &(2,1) references the Tag_*, and pull off the "**2ABC**" part
            "Property*": "&(2,1)_&"
          }
        }
      }
    }
  }
]
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46339616

复制
相关文章

相似问题

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