6

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.

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.

enter image description here

Sathyaraj
  • 189
  • 6
  • 21

1 Answers1

3

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

ekad
  • 14,436
  • 26
  • 44
  • 46
Mister X
  • 3,406
  • 3
  • 31
  • 72