Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Return a scalar value with EvaluateJSONPath processor

avatar
Expert Contributor

I need to use wildcard syntax in a JSON path to return the color of the bike as a scalar value.  However, the problem is that when I use wildcard syntax with the EvaluateJSONPath processor it always returns an array.  For example

This path returns a scalar value:     $.store.bicycle.color   ==>  red

This path returns an array:              $..bicycle.color         ==> ['red']         

Is it possible to use the EvaluateJSONPath processor with wildcards and get a scalar value in return? 

Or, is it possible to extract the value from the array without using an additional processor?

 

{
    "store": {
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    },
    "expensive": 10
}
                        

 

 

 

1 ACCEPTED SOLUTION

avatar
Super Guru

Hi,

I dont think there is a way to do that in one processor, check out this post around the problem with possible solution:

https://community.cloudera.com/t5/Support-Questions/Unable-to-return-a-scalar-value-for-the-expressi...

 

If you find this helpful please accept solution.

View solution in original post

2 REPLIES 2

avatar
Super Guru

Hi,

I dont think there is a way to do that in one processor, check out this post around the problem with possible solution:

https://community.cloudera.com/t5/Support-Questions/Unable-to-return-a-scalar-value-for-the-expressi...

 

If you find this helpful please accept solution.

avatar
Expert Contributor

Thanks @SAMSAL, I was tracking that previous post but since it was so old I was hoping newer versions of NiFi could address this.  This is such a simple thing with XML and the EvaluateXPath processor, I am just surprised that we can't do something similar with JSON.  Oh well, 2 processors it is.