NIFI:从JSON获取价值 [英] NIFI: get value from json

查看:724
本文介绍了NIFI:从JSON获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个queryCassandra,它生成像这样的json:

i have a queryCassandra which generate json like this one:

{"results":[{"term":"term1"},{"term":"term2"}..]}

现在,我想从中得到所有术语值,这些值用字符串格式的某些分隔符分隔;前任 : term1,term2,term3

Now, i want to get from this all the term values separated by some separator in string format; ex : term1,term2,term3

所以我可以将此列表作为我已经设置的Java主程序的字符串参数传递.

So i can pass this list as a string parameter for a java main program which i've alreat set.

(我只需要进行转换,而不需要执行Java程序)

(i only need the transofrmation, not the java program execution)

谢谢!

推荐答案

您可以使用以下方法轻松获取这些值.

You can easily get those values by using following ways.

GetFile-->EvaluateJsonPath-->PutFile

在获取文件中,您必须指定json文件的位置.

In get file you have to specify location of json file.

在EvaluateJsonPath中,像以下属性一样进行配置.

In EvaluateJsonPath configure like following properties.,

Destination:flowfile-attribute
Return Type:json
input.term1:$.results.[0].term           //To get term
input.term2:$.results.[1].term

在评估json的结果中,您具有两个具有这些值的属性.

At the result of Evaluate json you have two attributes in which having those values.

结果属性:

input.term1: term1

input.term2: term2

上面的代码对我有用,所以随时可以投票/接受作为答案.

Above code works for me,so feel free to upvote/accept as answer.

这篇关于NIFI:从JSON获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆