Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Nifi UpdateAttribute not able to replace \u2028 (
) , \u2029 characters in JSON files

Highlighted

Nifi UpdateAttribute not able to replace \u2028 (
) , \u2029 characters in JSON files

New Contributor

Hi I'm having problems with trying to replace \u2028 and \u2029 in JSON response using UpdateAttribute processor.

Without replacing this my next processor, ReplaceText , truncates the JSON causing it to become invalid.

Can someone help?

3 REPLIES 3

Re: Nifi UpdateAttribute not able to replace \u2028 (
) , \u2029 characters in JSON files

Super Guru

@Abhishek

Is it possible that, you can add sample input data and expected output?

Re: Nifi UpdateAttribute not able to replace \u2028 (
) , \u2029 characters in JSON files

New Contributor

@Shu Trying to do something like the attached, which doesn't work. Also tried the text form

${data:replace("\u2028", "")}

83488-u2028.png

Re: Nifi UpdateAttribute not able to replace \u2028 (
) , \u2029 characters in JSON files

Super Guru

@Abhishek

It would be lot more easier to have script that can go through the json message (or) attribute values and look for \u2028 character and replace with "".

Sample groovy script to replace the "\u2028"

def st = '
    ';
println st.replace("\u2028", "hi") 
Output:
hi

Like this way you can have the Groovy/python ..etc script and use ExecuteGroovyScript/ExecuteScript/InvokeScriptedProcessors to execute the script.

For more reference regarding scripting in nifi refer to this link.

Don't have an account?
Coming from Hortonworks? Activate your account here