5
votes

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?

3
it's not clear what is your goal.. - daggett
Sorry, my goal is to save each value in cassandra. Means that I can place a cql statement in replace text processor like this: insert into table (a, b, c) values ('${a}', '${b}', '${c}'). Hope that makes it clearer. - Max Testermann

3 Answers

3
votes

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
2
votes

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

1
votes

$.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