Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 201
Max Testermann Avatar asked Nov 04 '17 20:11

Max Testermann


People also ask

How do you evaluate a JSON path?

You can open up a window to evaluate JSONPath expressions by going to Edit -> Find -> "Evaluate JSONPath Expression...". If a JSON file is open, it will use this file to evaluate the expression. If you have JSONPath expressions as Strings in code, use "inject language" and say this is a JSONPath expression.

What is Apache NiFi used for?

Apache NiFi is an integrated data logistics platform for automating the movement of data between disparate systems. It provides real-time control that makes it easy to manage the movement of data between any source and any destination.

What is JSONPath expression?

A JSONPath expression specifies a path to an element (or a set of elements) in a JSON structure. Paths can use the dot notation: $.store.book[0].title. or the bracket notation: $['store']['book'][0]['title']

What are attributes in NiFi?

The attributes are key/value pairs that act as the metadata for the FlowFile, such as the FlowFile filename. The content is the actual data or the payload of the file. Provenance is a record of what has happened to the FlowFile.


1 Answers

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
like image 54
Max Testermann Avatar answered Oct 01 '22 23:10

Max Testermann