Max Testermann
Max Testermann

Reputation: 81

Apache nifi evaluateJsonPath splitJson

With the ConvertRecord processor I have converted a csv text file to a json file which looks like this:

[
   {"A":1001,"B":"20170101","C":0.3},

   {"A":1001,"B":"20170102","C":0.1},
 .....]

I tried with evaluate Json Path to get the pathes like:

a: $.A
b: $.B
....

But I got only null values.

Im not sure do I need to split this JSON file with SplitJson processor before using evaluateJsonPath and when yes, what do I need to enter in the processor?

I tried

$.*

But it didn't work.

Or do I just need to use other JsonPath values in evaluateJsonPath processor?

Upvotes: 5

Views: 5066

Answers (3)

Max Testermann
Max Testermann

Reputation: 81

thx for the answers. I found the solution. I had already the right way in my mind, so it was right to split the JSON at the path:

$.*

My mistake was a typo in the evaluateJsonPath processor. So after splitting I could just evaluate the json path like this:

a: $.A

Upvotes: 3

Mahendran V M
Mahendran V M

Reputation: 3496

Max,

You have to split json by using this expression $[*] in splitJSON Processor.

Afterwards you can use EvaluateJSONPath like expression $.A ,$.B to catch contents and so on.

Thanks

Upvotes: 2

OneCricketeer
OneCricketeer

Reputation: 192003

$.A assumes your JSON is only one object record.

You have a list.

$[*].A or $..A will return you a list of [1001, 1001] given your example

Upvotes: 1

Related Questions