Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

How to extract json array using EvaluateJsonPath processor in NiFi?

Rising Star

Hi,

I have json flowfile,  [{"prediction":"Test2"},{"prediction":"Test2"}].

 

I am want extract the 1st part of the array ie prediction":"Test2  my destination is flowfile-attribute using EvaluateJsonPath .

 

I have added a custom attribute mlresult --->$.prediction[0], to extract the "Test2" into mlresult, but I am getting empty string  for the mlresults for the flow file attribute section.

 

flow file : [{"prediction":"Test2"},{"prediction":"Test2"}]

EvaluateJsonPath configuration:

 

mlresult.PNG

 
 

 

 

How to get the value(only one)  Test2 to mlresult?

 

Thanks

--Murali

 

 

 

1 ACCEPTED SOLUTION

Expert Contributor

@murali2425 

Here are two possible solutions.

2021-03-01_HCC_json.png


At solution 1 the value is set into an array.

At solution 2 I took the flowfile-content (json) and set it into an attribute. Then you can work with expression language to get the value.


For testing the syntax I recommend this site:
http://jsonpath.herokuapp.com/

View solution in original post

1 REPLY 1

Expert Contributor

@murali2425 

Here are two possible solutions.

2021-03-01_HCC_json.png


At solution 1 the value is set into an array.

At solution 2 I took the flowfile-content (json) and set it into an attribute. Then you can work with expression language to get the value.


For testing the syntax I recommend this site:
http://jsonpath.herokuapp.com/

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.