Support Questions

Find answers, ask questions, and share your expertise

NiFi parameters - jsonPath function doesn't work on a parameter

Explorer

Hi There,

 

I am not able to use jsonPath function on a NiFi parameter. However the same works fine if it is a variable.

 

For eg. 

#{category_mappings:jsonPath("$.catCode")} - Doesn't work (snapshot attached)

${category_mappings:jsonPath("$.catCode")} - Works fine

 

Screen Shot 2021-06-02 at 12.56.04 PM.png

1 REPLY 1

Master Guru

@Maqbool 

Can you provide some more detail on what you are trying to accomplish here?

If we look at the NiFi Expression Language (NEL) example that does work you shared:

 

${category_mappings:jsonPath("$.catCode")}

 

NEL evaluates this as follows:
Finds NiFi variable with name "category_mappings" and return the value assigned to that variable (Depending on level of NEL support in the component property were this is used, it may search for that variable name in multiple places (FlowFile attributes, variable registry, java properties, environment variables).  The returned value is then passed to the NEL function :jsonPath().

Now if we look at your parameter context example:

#{category_mappings:jsonPath("$.catCode")}

It is looking for the parameter context with string "category_mappings:jsonPath("$.catCode")" which it did not find in the "Parameters" assigned to the Process Group in which this processor resides.
I suspect this is not what you really are trying to accomplish here.

I suspect that the parameter context you have in your parameters on this process group is really only "category_mappings" and you still need to use NEL in order to execute a NEL function against that parameter's value.

${#{category_mappings}:jsonPath("$.catCode")}

You'll notice the slight difference here.  We now have a NEL statement that gets its subject from a parameter "category_mappings" instead of variable and passes that value to the NEL ":jsonPath()" function.

If you found this addresses your query, please take a moment to login and click "Accept" on this solution.
Thank you,
Matt

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