Member since
08-12-2021
4
Posts
0
Kudos Received
0
Solutions
08-24-2021
10:59 AM
@smartraman This can also be accomplished through a different and more complex configuration of the ReplaceText processor: Using below input content example: {
"TOT_NET_AMT" : "[\"55.00\"]",
"H_OBJECT" : "File",
"H_GROSS_AMNT" : "[\"55.00,58.00\"]",
"TOT_TAX_AMT" : "[9.55]"
} I would set up the replaceText processor as follows: Instead of just searching for those character patterns and replacing them with nothing, I break entire input line-by-line in to a series of capture groups. That way I can omit the capture groups matching the patterns you want removed ([ or [\" or \"] or ]) and then manipulate the capture group containing a possible comma separated list, so that only the last value in that list is returned. I used below java regular expression which results in 5 capture groups: (.*?)([\Q[\E]\\\"|[\Q[\E])(.*?)(\\\"[\Q]\E]|[\Q]\E])(.*?)$ I then used the following Replacement Value in which I used NiFi expression language against the 3rd capture group. If that capture group does not contain any commas, the entire string is returned. With example above and this configuration, you end up with the following new content: {
"TOT_NET_AMT" : "55.00",
"H_OBJECT" : "File",
"H_GROSS_AMNT" : "58.00",
"TOT_TAX_AMT" : "9.55"
} If you found this helped with your latest query, please take a moment to login and click on "Accept as Solution" below this response. Thank you, Matt
... View more
08-18-2021
04:55 PM
Thanks @adhishankarit for your help. The value of H gross amount is in List ["55.00","58.00"] it's coming from flowfile attribute. Will, it is possible to get the attribute value of H gross amount to use Jolt transformation JSON NiFi processor with the same as last element of H gross amount? Thanks In advance.
... View more