Created 01-25-2021 04:20 AM
Hi All,
I am trying to build JSON string using Ifelse condition in ReplaText processor but i am getting error as invalid Invalid Expression .
Working Ifelse condition :
${status:contains('0'):ifElse('Success','Failed')}
This below string is not working and it is throwing invalid expression . Please assist on this .
${status:contains('0'):ifElse('{
"filename":"${overall_filename}",
"status":"${status}",
"message":"${overall_message}"
}',
'{
"filename":"${overall_filename}",
"status":"${exc_status}",
"message":"${overall_message}"
}'
)
}
Thanks
Created 01-25-2021 06:19 AM
@adhishankarit
The issues is being caused by the line returns used in the middle of the NiFi NiFiExpression Language (EL) ifElse() function you are using.
The text box where you enter your NiFi EL uses a NiFi editor that highlights to show proper EL format. You'll notice your EL stops highlighting once you reach first line return. So you'll notice character 32 is the first single quote character. Since EL breaks at this point it fails to find the matching second expected single quote.
This leaves you with two options:
1. Create flat json without the line returns.
2. Looking at result you are trying to achieve, design your NiFi EL differently:
Note proper NiFi EL highlighting above.
Hope this helps,
Matt
Created 01-25-2021 06:19 AM
@adhishankarit
The issues is being caused by the line returns used in the middle of the NiFi NiFiExpression Language (EL) ifElse() function you are using.
The text box where you enter your NiFi EL uses a NiFi editor that highlights to show proper EL format. You'll notice your EL stops highlighting once you reach first line return. So you'll notice character 32 is the first single quote character. Since EL breaks at this point it fails to find the matching second expected single quote.
This leaves you with two options:
1. Create flat json without the line returns.
2. Looking at result you are trying to achieve, design your NiFi EL differently:
Note proper NiFi EL highlighting above.
Hope this helps,
Matt