- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Return a scalar value with EvaluateJSONPath processor
- Labels:
-
Apache NiFi
Created on ‎10-12-2022 04:27 PM - edited ‎10-12-2022 06:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
}
Created ‎10-13-2022 06:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I dont think there is a way to do that in one processor, check out this post around the problem with possible solution:
If you find this helpful please accept solution.
Created ‎10-13-2022 06:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I dont think there is a way to do that in one processor, check out this post around the problem with possible solution:
If you find this helpful please accept solution.
Created ‎10-13-2022 08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
