Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

nifi EvaluateJsonPath could not find path in json flowfile generated from avro file

avatar
Expert Contributor

This data is transfered from CSV to Avro and from avro to json in order to fetch one columns value in flowfile attribute and route on that value But my EvaluateJsonPath processor cannot recognize the path

log out put

2017-09-22 11:10:32,402 WARN [Timer-Driven Process Thread-9] o.a.n.p.standard.EvaluateJsonPath EvaluateJsonPath[id=d7e53856-262e-12a7-b651-7eff7b6fd820] FlowFile 6908917 could not find path $['zip'] for attribute key zip.: com.jayway.jsonpath.PathNotFoundException: Property ['zip'] not found in path 

avro schema attribute and example data json format

inferred.avro.schema
{ "type" : "record", "name" : "CSRPrecord", "doc" : "Schema generated by Kite", "fields" : [ { "name" : "name", "type" : "string", "doc" : "Type inferred from 'Simon jespersen'" }, { "name" : "adresse", "type" : "string", "doc" : "Type inferred from 'Brejning S.ndetrgade 66'" }, { "name" : "zip", "type" : "long", "doc" : "Type inferred from '7080'" }, { "name" : "by", "type" : "string", "doc" : "Type inferred from 'B.rkop'" } ] }
example data content of flowfile
[{"name": "else", "adresse": "route 66", "zip": 7000, "by": "Hortownworks City"},{"name": "Karina", "adresse": "Route 66", "zip": 7001, "by": "Hadoop City"},{"name": "Luke Skyewalker", "adresse": "some where in the universe", "zip": 1111, "by": "SinCity"},{"name": "Superman", "adresse": "Krypto street 1", "zip": 0001, "by": "Metroplitan"}]
I cannot understand why i cannot evalutae the json path 

<br>

look at the attachment picture to see my EvaluateJsonPath configuration

evaljsonpath.png
1 REPLY 1

avatar
Master Guru

Hi @Simon Jespersen,
in your evalJsonpath processor you are using Path Not Found Behavior property as warn i.e it will generate a warning when a JSON path expression is not found, as in your csv file you are for some of the records wont have any data for zip.
This warn message wont effect your flowfile, flowfile still routes to success relationship with all the available content will be extracted as attributes and for no content attributes values will be Empty string set.
if you don't want to see those warn messages on the processor then just change

Path Not Found Behavior property to ignore(default)

which will ignore if the content is not found for any of the processor.

Example:-
i have recreated same WARN message as you are having with the below Json doc

{
  "name" : "else",
  "adresse" : "route 66",
  "by" : "Hadoop City" <br>}

with ignore property
This is my json doc to evaljson processor with ignore as path not found property processor wont return any warn messages as it ignore if there is no content for the jsonpath expression.

40478-evaluate-conf.png

With warn property:-

If you change path not found property to warn processor will return the same warn message as you are having in the question.

both cases results the same output as zip attribute value is Empty string set and routes to Success relation.

40479-attributes-eval.png