<?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: how to extract fields in flow file which are surrounded by  square brackets in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208637#M170594</link>
    <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; thank you very much for your help and support . I willtry this solution &lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2018 19:00:23 GMT</pubDate>
    <dc:creator>sdendukuri</dc:creator>
    <dc:date>2018-10-09T19:00:23Z</dc:date>
    <item>
      <title>how to extract fields in flow file which are surrounded by  square brackets</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208635#M170592</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;How extract fields from flow file in json format are in square brackets. I am using Evaluate json path processor  but not getting results . Please help me on this regards&lt;/P&gt;&lt;P&gt;[{"projetname":"ABC", "projectid":  "ABC-12", "startdate" :"Aug-2018"}]&lt;/P&gt;&lt;P&gt;I was used the evaluate json path processor :  projectidvariable  --&amp;gt;  "projectid":\s(.*?),&lt;/P&gt;&lt;P&gt;Thanks for your time and consideration &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 04:02:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208635#M170592</guid>
      <dc:creator>sdendukuri</dc:creator>
      <dc:date>2018-10-09T04:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract fields in flow file which are surrounded by  square brackets</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208636#M170593</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/73297/sdendukuri.html" nodeid="73297" target="_blank"&gt;@Suresh Dendukuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EvaluateJsonPath&lt;/STRONG&gt; processor accepts only valid &lt;STRONG&gt;json path's(ex:$.&amp;lt;key&amp;gt;..) &lt;/STRONG&gt;as you are specifying &lt;STRONG&gt;Regex&lt;/STRONG&gt; if you want to &lt;STRONG&gt;extract the values using Regex then use ExtractText processor and add your regex path in that processor.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Configure &lt;STRONG&gt;EvaluateJsonPath&lt;/STRONG&gt; processor as shown below and keep &lt;STRONG&gt;Destination as flowfile-attributes&lt;/STRONG&gt; and add &lt;STRONG&gt;new properties &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91650-screen-shot-2018-10-08-at-60056-pm.png" style="width: 1534px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16851iF96D479EBC59ADB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91650-screen-shot-2018-10-08-at-60056-pm.png" alt="91650-screen-shot-2018-10-08-at-60056-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;projectid&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;$.[0].projectid&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;projetname&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;$.[0].projetname&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;startdate&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;$.[0].startdate&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Output:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91651-screen-shot-2018-10-08-at-60256-pm.png" style="width: 698px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16852i19D50B7DA736559C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91651-screen-shot-2018-10-08-at-60256-pm.png" alt="91651-screen-shot-2018-10-08-at-60256-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you see in the above screenshot attributes are added to the flowfile, This way we are assuming there are only one json message in array and extracting the first message values and storing as flowfile attributes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;EM&gt;Cleaner way to do this task as follows:&lt;/EM&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;as you are having array of json messages and want's to extract the values of the json key's so &lt;STRONG&gt;split the array of json messages&lt;/STRONG&gt; into individual messages by using &lt;STRONG&gt;SplitJson&lt;/STRONG&gt; processor.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SplitJsonConfigs:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91652-screen-shot-2018-10-08-at-60522-pm.png" style="width: 976px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16853i8716AD846F5B1C63/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91652-screen-shot-2018-10-08-at-60522-pm.png" alt="91652-screen-shot-2018-10-08-at-60522-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then use EvaluateJsonPath processor:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91653-screen-shot-2018-10-08-at-60631-pm.png" style="width: 1456px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16854i84E4C35475BA404B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91653-screen-shot-2018-10-08-at-60631-pm.png" alt="91653-screen-shot-2018-10-08-at-60631-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Configure the processor as show above this will work if you are having more than one json message in an array also.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 04:21:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208636#M170593</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T04:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract fields in flow file which are surrounded by  square brackets</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208637#M170594</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; thank you very much for your help and support . I willtry this solution &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 19:00:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/208637#M170594</guid>
      <dc:creator>sdendukuri</dc:creator>
      <dc:date>2018-10-09T19:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract fields in flow file which are surrounded by  square brackets</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/269034#M206583</link>
      <description>&lt;P&gt;Hey can you please help me with extracting regex attribute from a json file&lt;FONT&gt;. I am trying to take attribute from a json file, this attributes have regex values. For ex: json file is - { "key1" : "(.{2})(.{4})", "key2" : "$1,$2"}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;From this json file I would need to take key1 and key2 in replacetext processor to search(key1) and replace by (key2). Please suggest a way to do this. Thanks!!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 09:06:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-extract-fields-in-flow-file-which-are-surrounded-by/m-p/269034#M206583</guid>
      <dc:creator>ansh_v</dc:creator>
      <dc:date>2019-08-27T09:06:56Z</dc:date>
    </item>
  </channel>
</rss>

