<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Removing Special Characters from JSON in NIFI in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322528#M228833</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/91156"&gt;@smartraman&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can use a ReplaceText processor to remove these special characters from your json.&lt;BR /&gt;Using your example, I could produce yoru desired output using the following java regular expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(\\")|[\Q[\E]|[\Q]\E]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_2-1628865095458.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32073i4521EB2C49909894/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_2-1628865095458.png" alt="MattWho_2-1628865095458.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My ReplaceText processor was configured as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1628864989816.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32071iA03CE2E7081E211E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1628864989816.png" alt="MattWho_0-1628864989816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1628865039271.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32072i9B8CAD893C1840AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_1-1628865039271.png" alt="MattWho_1-1628865039271.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you found this response addressed your query, please take a moment to login and click on "Accept as Solution".&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
    <pubDate>Fri, 13 Aug 2021 14:33:43 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2021-08-13T14:33:43Z</dc:date>
    <item>
      <title>Removing Special Characters from JSON in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322490#M228813</link>
      <description>&lt;P&gt;Hi Support Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have JSON input for Nifi flow with some special characters. Could someone help me with how to remove&amp;nbsp;special characters following payload? we would need only value with array and double-quotes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input json: -&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"TOT_NET_AMT" : "[\"55.00\"]",&lt;BR /&gt;"H_OBJECT" : "File",&lt;BR /&gt;"H_GROSS_AMNT" : "[\"55.00\"]",&lt;BR /&gt;"TOT_TAX_AMT" : "[9.55]"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expect Result :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"TOT_NET_AMT" : "55.00",&lt;BR /&gt;"H_OBJECT" : "File",&lt;BR /&gt;"H_GROSS_AMNT" : "55.00",&lt;BR /&gt;"TOT_TAX_AMT" : "9.55"&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 02:38:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322490#M228813</guid>
      <dc:creator>smartraman</dc:creator>
      <dc:date>2021-08-13T02:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Special Characters from JSON in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322528#M228833</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/91156"&gt;@smartraman&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can use a ReplaceText processor to remove these special characters from your json.&lt;BR /&gt;Using your example, I could produce yoru desired output using the following java regular expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(\\")|[\Q[\E]|[\Q]\E]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_2-1628865095458.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32073i4521EB2C49909894/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_2-1628865095458.png" alt="MattWho_2-1628865095458.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My ReplaceText processor was configured as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1628864989816.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32071iA03CE2E7081E211E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1628864989816.png" alt="MattWho_0-1628864989816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1628865039271.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32072i9B8CAD893C1840AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_1-1628865039271.png" alt="MattWho_1-1628865039271.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you found this response addressed your query, please take a moment to login and click on "Accept as Solution".&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 14:33:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322528#M228833</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2021-08-13T14:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Special Characters from JSON in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322651#M228891</link>
      <description>&lt;P&gt;Hi Support,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the previous help. but some time input payloads have multiple entries in this list format after replacing regex the below output came. but we are expecting&amp;nbsp;H_GROSS_AMNT following the below details.&lt;/P&gt;&lt;P&gt;we would need the last value of the array or string.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"TOT_NET_AMT" : "55.00",&lt;BR /&gt;"H_OBJECT" : "File",&lt;BR /&gt;"H_GROSS_AMNT" : "&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;55.00,58.00&lt;/STRONG&gt;&lt;/FONT&gt;",&lt;BR /&gt;"TOT_TAX_AMT" : "9.55"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected value -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"TOT_NET_AMT" : "55.00",&lt;BR /&gt;"H_OBJECT" : "File",&lt;BR /&gt;"H_GROSS_AMNT" : "&lt;FONT color="#008000"&gt;&lt;STRONG&gt;58.00&lt;/STRONG&gt;&lt;/FONT&gt;",&lt;BR /&gt;"TOT_TAX_AMT" : "9.55"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciate it in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 03:10:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/322651#M228891</guid>
      <dc:creator>smartraman</dc:creator>
      <dc:date>2021-08-17T03:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Special Characters from JSON in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/323096#M229019</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/91156"&gt;@smartraman&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This can also be accomplished through a different and more complex configuration of the ReplaceText processor:&lt;BR /&gt;&lt;BR /&gt;Using below input content example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"TOT_NET_AMT" : "[\"55.00\"]",
"H_OBJECT" : "File",
"H_GROSS_AMNT" : "[\"55.00,58.00\"]",
"TOT_TAX_AMT" : "[9.55]"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would set up the replaceText processor as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1629827182325.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32149i7AC63DC1FF9012AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1629827182325.png" alt="MattWho_0-1629827182325.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; That way I can omit the capture groups matching the patterns you want removed (&lt;FONT color="#FF0000"&gt;[&lt;/FONT&gt; or &lt;FONT color="#FF0000"&gt;[\" &lt;FONT color="#000000"&gt;or&lt;/FONT&gt;&amp;nbsp;\"]&amp;nbsp;&lt;FONT color="#000000"&gt;or &lt;FONT color="#FF0000"&gt;]&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;) and then manipulate the capture group containing a possible comma separated list, so that only the last value in that list is returned.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I used below java regular expression which results in 5 capture groups:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(.*?)([\Q[\E]\\\"|[\Q[\E])(.*?)(\\\"[\Q]\E]|[\Q]\E])(.*?)$&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I then used the following Replacement Value in which I used NiFi expression language against the 3rd capture group.&amp;nbsp; If that capture group does not contain any commas, the entire string is returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With example above and this configuration, you end up with the following new content:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"TOT_NET_AMT" : "55.00",
"H_OBJECT" : "File",
"H_GROSS_AMNT" : "58.00",
"TOT_TAX_AMT" : "9.55"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you found this helped with your latest query, please take a moment to login and click on "Accept as Solution" below this response.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 17:59:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Removing-Special-Characters-from-JSON-in-NIFI/m-p/323096#M229019</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2021-08-24T17:59:41Z</dc:date>
    </item>
  </channel>
</rss>

