I'm trying to get the attribute values from a JSON file using EvaluvateJsonPath processer in NiFi.
Below is the sample JSON file
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}
Below is my configuration.
The expected output should be "main_window". But i'm getting the whole JSON string as the output. Can someone please point me in the right direction, what went wrong here?
Update:
This is the flow file content, i'm seeing in the queue as an outcome of EvaluvateJsonPath processer.
The most common attributes you'll see are filename , path and uuid . The string in parentheses is the value of the attribute within the CoreAttributes enum and how it appears in the UI/API. Filename ( filename ): The filename of the FlowFile.
Data of the flowfiles is stored in 3 directories on disk, flowfile repository - persists attributes of the flowfile. content repository - stores all data contained in the flowfile. provenance repository - stores information about the history of the flowfile.
As an example, to alter the standard "filename" attribute so that it has ". txt" appended to the end of it, add a new property and make the property name "filename" (to reference the desired attribute), and as the value, use the NiFi Expression Language statement shown below: Property: filename. Value: ${filename}.
You have given "Name"-->$.widget.window.name
correctly.
But you have to specify "ReturnType"-->json
not to be "ReturnType"-->autodetect
.
That's the problem for you have received whole json string.
EDIT-1
If you change return type to be json then you can receive your expected output "main_window"` to be stored in Attribute ${Name}.
After that you can use ReplaceText processor to Specify replacement value "${Name}" then you can receive "main_window" in flowfile
It could be worked for me.
And Let me know if you face any issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With