<?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: find last element of json in nifi in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322785#M228925</link>
    <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your input json is coming below format&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;STRONG&gt;["55.00","58.00"],&lt;/STRONG&gt;&lt;BR /&gt;"TOT_TAX_AMT" : "9.55"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;If the value of H gross amount is in List of String &lt;STRONG&gt;["55.00","58.00"] &lt;/STRONG&gt;&amp;nbsp;instead of String&amp;nbsp;"55.00,58.00" , then you can use Jolt transformation JSON NiFi processor to define jolt spec to convert into the required output.&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" : "58.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;Jolt transformation JSON configuration.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adhishankarit_0-1629321625436.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32110i8B95A9E88F99877D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adhishankarit_0-1629321625436.png" alt="adhishankarit_0-1629321625436.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jolt specification :&amp;nbsp;&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"operation": "modify-overwrite-beta",&lt;BR /&gt;"spec": {&lt;BR /&gt;"H_GROSS_AMNT": "=lastElement(@(1,H_GROSS_AMNT))"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the input is not list of String for H Gross amount and only string with comma speparated, then please follow the below steps in order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you will have to extract whole json into single attribute using extracttext processor and the attribute will hold entire json content , Next you can use EvaluateJsonPath which extracts each json element into each attributes , once you have all 4 attributes with value after&amp;nbsp;EvaluateJsonPath , then you construct the json in Replace text processor ,H_GROSS_AMNT will still hold the string comma separated and u can use&amp;nbsp;H_GROSS_AMNT:&lt;SPAN&gt;substringAfterLast(,) which extracts last element from the string value .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examples of&amp;nbsp;EvaluateJsonPath&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Aug 2021 21:20:55 GMT</pubDate>
    <dc:creator>adhishankarit</dc:creator>
    <dc:date>2021-08-18T21:20:55Z</dc:date>
    <item>
      <title>find last element of json in nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322690#M228899</link>
      <description>&lt;P&gt;One of the JSON values needs to find the string last element. how to get the particular value in attribute with the last element.&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 16:22:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322690#M228899</guid>
      <dc:creator>smartraman</dc:creator>
      <dc:date>2021-08-17T16:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: find last element of json in nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322785#M228925</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your input json is coming below format&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;STRONG&gt;["55.00","58.00"],&lt;/STRONG&gt;&lt;BR /&gt;"TOT_TAX_AMT" : "9.55"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;If the value of H gross amount is in List of String &lt;STRONG&gt;["55.00","58.00"] &lt;/STRONG&gt;&amp;nbsp;instead of String&amp;nbsp;"55.00,58.00" , then you can use Jolt transformation JSON NiFi processor to define jolt spec to convert into the required output.&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" : "58.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;Jolt transformation JSON configuration.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adhishankarit_0-1629321625436.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32110i8B95A9E88F99877D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adhishankarit_0-1629321625436.png" alt="adhishankarit_0-1629321625436.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jolt specification :&amp;nbsp;&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"operation": "modify-overwrite-beta",&lt;BR /&gt;"spec": {&lt;BR /&gt;"H_GROSS_AMNT": "=lastElement(@(1,H_GROSS_AMNT))"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the input is not list of String for H Gross amount and only string with comma speparated, then please follow the below steps in order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you will have to extract whole json into single attribute using extracttext processor and the attribute will hold entire json content , Next you can use EvaluateJsonPath which extracts each json element into each attributes , once you have all 4 attributes with value after&amp;nbsp;EvaluateJsonPath , then you construct the json in Replace text processor ,H_GROSS_AMNT will still hold the string comma separated and u can use&amp;nbsp;H_GROSS_AMNT:&lt;SPAN&gt;substringAfterLast(,) which extracts last element from the string value .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examples of&amp;nbsp;EvaluateJsonPath&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 21:20:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322785#M228925</guid>
      <dc:creator>adhishankarit</dc:creator>
      <dc:date>2021-08-18T21:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: find last element of json in nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322786#M228926</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/57238"&gt;@adhishankarit&lt;/a&gt;&amp;nbsp;&amp;nbsp; for your help.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The value of H gross amount is in List&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;["55.00","58.00"]&amp;nbsp;&lt;/STRONG&gt;it's coming from flowfile attribute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will, it is possible to get the attribute value of&amp;nbsp;&lt;SPAN&gt;H gross amount to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;use Jolt transformation JSON NiFi processor with the same as last element&amp;nbsp;of&amp;nbsp;H gross amount?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks In advance.&lt;/SPAN&gt;&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>Thu, 19 Aug 2021 00:02:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/find-last-element-of-json-in-nifi/m-p/322786#M228926</guid>
      <dc:creator>smartraman</dc:creator>
      <dc:date>2021-08-19T00:02:58Z</dc:date>
    </item>
  </channel>
</rss>

