NIFI:从 json 获取值 [英] NIFI: get value from json
问题描述
我有一个 queryCassandra,它生成这样的 json:
i have a queryCassandra which generate json like this one:
{"results":[{"term":"term1"},{"term":"term2"}..]}
现在,我想从中获取由字符串格式的某个分隔符分隔的所有术语值;前任 :学期1、学期2、学期3
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
在 Evaluate 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屋!