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.

Fix Invalid JSON

Highlighted

Fix Invalid JSON

New Contributor

Hello - I have some JSON in flowfile content that I need to fix. I essentially have a string field with "Double Quotes" around it and I need to remove the ""Double Double Quotes"" that was created when I did an AttributeToJSON call. I am able to find the beginning and ending double double quotes using a Regex in ReplaceText, but I have not been able to replace the text in multiple instances. It replaces every instance with the first $1.

Here is my text

{"usb_cust_exception":"","process_flow_name":""ICS Pending Authorizations"","invoked-component-name":""Convert Record"","process_group_name":""Ingest Inbound Payload"","uuid":"1c661034-a999-41bd-ae51-4a8ceaffc13f","current_timestamp":"2019-02-04 14:14:11.638"}

When I call ReplaceText, I use

(""[A-Za-z])

for Search and

${'$1':replace('""', '"')}

for Replace.

It works on the first one, but the rest it uses the same text. How do I incorporate $2, $3, $4, etc? I need it to look like this when I'm done:

{"usb_cust_exception":"","process_flow_name":"ICS Pending Authorizations","invoked-component-name":"Convert Record","process_group_name":"Ingest Inbound Payload","uuid":"1c661034-a999-41bd-ae51-4a8ceaffc13f","current_timestamp":"2019-02-04 14:14:11.638"}

Thanks in advance

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