<?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 Add flow attribute from Json in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349012#M235499</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add flow attribute from my json file which looks like:&lt;/P&gt;&lt;P&gt;[ {&lt;BR /&gt;"name" : "id",&lt;BR /&gt;"value" : "29879"&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "file",&lt;BR /&gt;"value" : ""&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "barcode",&lt;BR /&gt;"value" : ""&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "roll no",&lt;BR /&gt;"value" : "3032"&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "name",&lt;BR /&gt;"value" : "Daniel"&lt;BR /&gt;}]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to add roll no. as a flow atrribute using&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="evaljson.PNG" style="width: 657px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35063iC8382BADE1B81FB8/image-dimensions/657x424?v=v2" width="657" height="424" role="button" title="evaljson.PNG" alt="evaljson.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me with it? Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2022 15:05:33 GMT</pubDate>
    <dc:creator>divnid</dc:creator>
    <dc:date>2022-07-28T15:05:33Z</dc:date>
    <item>
      <title>Add flow attribute from Json</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349012#M235499</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add flow attribute from my json file which looks like:&lt;/P&gt;&lt;P&gt;[ {&lt;BR /&gt;"name" : "id",&lt;BR /&gt;"value" : "29879"&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "file",&lt;BR /&gt;"value" : ""&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "barcode",&lt;BR /&gt;"value" : ""&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "roll no",&lt;BR /&gt;"value" : "3032"&lt;BR /&gt;}, {&lt;BR /&gt;"name" : "name",&lt;BR /&gt;"value" : "Daniel"&lt;BR /&gt;}]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to add roll no. as a flow atrribute using&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="evaljson.PNG" style="width: 657px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35063iC8382BADE1B81FB8/image-dimensions/657x424?v=v2" width="657" height="424" role="button" title="evaljson.PNG" alt="evaljson.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me with it? Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:05:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349012#M235499</guid>
      <dc:creator>divnid</dc:creator>
      <dc:date>2022-07-28T15:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add flow attribute from Json</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349027#M235503</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;If you want to extract the value (3032) of the name "roll no" into flowfile attribute called "roll no" you can accomplish this with two processors as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1- EvaluateJsonPath:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; roll no = $.[?(@.name=='roll no')].value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Make sure the Return Type is set to &lt;STRONG&gt;Json &lt;/STRONG&gt;since the exrepssion above will return json ["3032"].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_0-1659035286850.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35065i811F8C4DD13B99B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_0-1659035286850.png" alt="SAMSAL_0-1659035286850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- Update Attribute : which will extract the actual value from result json above with the following&amp;nbsp; attribute:&amp;nbsp;&amp;nbsp; roll no = ${'roll no':jsonPath('$[0]')}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_1-1659035395931.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35066iF872F6DAB23CF902/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_1-1659035395931.png" alt="SAMSAL_1-1659035395931.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also you can refer to :&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/t5/Support-Questions/Unable-to-return-a-scalar-value-for-the-expression-from-NIFI/td-p/213677" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/Unable-to-return-a-scalar-value-for-the-expression-from-NIFI/td-p/213677&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that helps, please Accept Solution. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 19:10:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349027#M235503</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-28T19:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Add flow attribute from Json</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349068#M235520</link>
      <description>&lt;P&gt;It worked for me. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 12:03:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Add-flow-attribute-from-Json/m-p/349068#M235520</guid>
      <dc:creator>divnid</dc:creator>
      <dc:date>2022-07-29T12:03:07Z</dc:date>
    </item>
  </channel>
</rss>

