<?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: NIFI | nifi Extract content from json array into separate attribute in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400947#M251012</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123543"&gt;@AbhiTryingAgain&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Welcome to the community and to Apache NiFi.&lt;BR /&gt;&lt;BR /&gt;Before building Dataflows it is important to understand the basics of a NiFi FlowFile.&amp;nbsp; This will help you navigate the available processor components and the expectations on what they do at a high level.&amp;nbsp; NiFi utilizes FlowFile so that it can remain data agnostic allowing NiFi to handle content of any type.&amp;nbsp; Now performing actions against the content of a FlowFile would require processors that can understand the data format of the content.&lt;BR /&gt;&lt;BR /&gt;A NiFi FlowFile is what is transferred from one NiFi Processor on the canvas to the next.&lt;BR /&gt;A FlowFile consists of&amp;nbsp; two parts:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;FlowFile Content- This is the actual binary data/content.&amp;nbsp; NiFi persist this content in content claims within the NiFi content_repository.&lt;/LI&gt;&lt;LI&gt;FlowFile Attributes/Metadata - This is attributes and metadata about the content and FlowFile. At the most basic level, all FlowFiles will have timestamps, filename, etc attributes.&amp;nbsp; Various NiFi processor will add even more attributes to a FlowFile.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Understanding above, NiFi processors like "RouteOnAttribute" never look at the content of a FlowFile, it only looks at the FlowFile attributes of a FlowFile and route the FlowFile to the specified dynamic downstream relationship.&amp;nbsp; &amp;nbsp;So when you setup three routes, they all evaluated to 'true' and FlowFile was cloned and routed to all three downstream relationships.&lt;BR /&gt;&lt;BR /&gt;What you need is a NiFi processor that will evaluate the multiple json records in your FlowFile's content and output multiple FlowFiles based on a unique category value.&lt;BR /&gt;&lt;BR /&gt;For this, I think the PartitionRecord processor is whet you could use.&amp;nbsp; This avoids splitting you Json record in to multiple records and then merging the various splits back into single FlowFiles based on category.&amp;nbsp; You can then use the JsonTreeReader and JsonRecordSetWriters.&amp;nbsp; Based on your example, configurations would look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1737730552733.png" style="width: 703px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43661iB82AB7F32B4DA382/image-dimensions/703x492?v=v2" width="703" height="492" role="button" title="MattWho_0-1737730552733.png" alt="MattWho_0-1737730552733.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1737730588906.png" style="width: 708px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43662i88729805F554EC72/image-dimensions/708x494?v=v2" width="708" height="494" role="button" title="MattWho_1-1737730588906.png" alt="MattWho_1-1737730588906.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_3-1737730783060.png" style="width: 708px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43664i2173F25C100EF34E/image-dimensions/708x494?v=v2" width="708" height="494" role="button" title="MattWho_3-1737730783060.png" alt="MattWho_3-1737730783060.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help our community thrive. If you found&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on&amp;nbsp;&lt;STRONG&gt;one or more&lt;/STRONG&gt;&amp;nbsp;of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2025 15:01:20 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2025-01-24T15:01:20Z</dc:date>
    <item>
      <title>NIFI | nifi Extract content from json array into separate attribute</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400876#M250981</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a json in the below format&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"order_id": 1,&lt;BR /&gt;"category": 123&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"order_id": 2,&lt;BR /&gt;"category": 123&amp;nbsp;&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"order_id": 3,&lt;BR /&gt;"category": 456&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"order_id": 4,&lt;BR /&gt;"category": 321&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create flowfiles seperatly for all the categories,&lt;/P&gt;&lt;P&gt;flowfile1 - orders of category 123:&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"order_id": 1,&lt;BR /&gt;"category": 123&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"order_id": 2,&lt;BR /&gt;"category": 123&amp;nbsp;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;flowfile2 - orders of category 456&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"order_id": 3,&lt;BR /&gt;"category": 456&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;flowfile3 - orders of category 321:&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"order_id": 4,&lt;BR /&gt;"category": 321&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't want to use splitjson, because this will be applied on millions of records. I don't want millions of flowfiles.&lt;BR /&gt;I tried &lt;STRONG&gt;EvaluateJsonPath&lt;/STRONG&gt; and &lt;STRONG&gt;RouteOnAttribute&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;all_category : $.[*].category - this creates on attribute with all category values&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RouteOnAttribute&amp;nbsp;&lt;BR /&gt;category_123 : ${all_category:contains(123)}&lt;BR /&gt;category_321 : ${all_category:contains(321)}&lt;BR /&gt;category_456 : ${all_category:contains(456)}&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But all the 3 flowfiles routed has all the order details.&lt;/P&gt;&lt;P&gt;Please guide me here, I am new to NIFI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 20:47:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400876#M250981</guid>
      <dc:creator>AbhiTryingAgain</dc:creator>
      <dc:date>2025-01-22T20:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI | nifi Extract content from json array into separate attribute</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400877#M250982</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123543"&gt;@AbhiTryingAgain&lt;/a&gt;&amp;nbsp;Welcome to the Cloudera Community!&lt;BR /&gt;&lt;BR /&gt;To help you get the best possible solution, I have tagged our NiFi experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp; who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please keep us updated on your post, and we hope you find a satisfactory solution to your query.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 20:52:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400877#M250982</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2025-01-22T20:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI | nifi Extract content from json array into separate attribute</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400947#M251012</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123543"&gt;@AbhiTryingAgain&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Welcome to the community and to Apache NiFi.&lt;BR /&gt;&lt;BR /&gt;Before building Dataflows it is important to understand the basics of a NiFi FlowFile.&amp;nbsp; This will help you navigate the available processor components and the expectations on what they do at a high level.&amp;nbsp; NiFi utilizes FlowFile so that it can remain data agnostic allowing NiFi to handle content of any type.&amp;nbsp; Now performing actions against the content of a FlowFile would require processors that can understand the data format of the content.&lt;BR /&gt;&lt;BR /&gt;A NiFi FlowFile is what is transferred from one NiFi Processor on the canvas to the next.&lt;BR /&gt;A FlowFile consists of&amp;nbsp; two parts:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;FlowFile Content- This is the actual binary data/content.&amp;nbsp; NiFi persist this content in content claims within the NiFi content_repository.&lt;/LI&gt;&lt;LI&gt;FlowFile Attributes/Metadata - This is attributes and metadata about the content and FlowFile. At the most basic level, all FlowFiles will have timestamps, filename, etc attributes.&amp;nbsp; Various NiFi processor will add even more attributes to a FlowFile.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Understanding above, NiFi processors like "RouteOnAttribute" never look at the content of a FlowFile, it only looks at the FlowFile attributes of a FlowFile and route the FlowFile to the specified dynamic downstream relationship.&amp;nbsp; &amp;nbsp;So when you setup three routes, they all evaluated to 'true' and FlowFile was cloned and routed to all three downstream relationships.&lt;BR /&gt;&lt;BR /&gt;What you need is a NiFi processor that will evaluate the multiple json records in your FlowFile's content and output multiple FlowFiles based on a unique category value.&lt;BR /&gt;&lt;BR /&gt;For this, I think the PartitionRecord processor is whet you could use.&amp;nbsp; This avoids splitting you Json record in to multiple records and then merging the various splits back into single FlowFiles based on category.&amp;nbsp; You can then use the JsonTreeReader and JsonRecordSetWriters.&amp;nbsp; Based on your example, configurations would look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1737730552733.png" style="width: 703px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43661iB82AB7F32B4DA382/image-dimensions/703x492?v=v2" width="703" height="492" role="button" title="MattWho_0-1737730552733.png" alt="MattWho_0-1737730552733.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1737730588906.png" style="width: 708px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43662i88729805F554EC72/image-dimensions/708x494?v=v2" width="708" height="494" role="button" title="MattWho_1-1737730588906.png" alt="MattWho_1-1737730588906.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_3-1737730783060.png" style="width: 708px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43664i2173F25C100EF34E/image-dimensions/708x494?v=v2" width="708" height="494" role="button" title="MattWho_3-1737730783060.png" alt="MattWho_3-1737730783060.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help our community thrive. If you found&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;any&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Accept as Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" on&amp;nbsp;&lt;STRONG&gt;one or more&lt;/STRONG&gt;&amp;nbsp;of them that helped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;BR /&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 15:01:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/400947#M251012</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2025-01-24T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI | nifi Extract content from json array into separate attribute</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/401423#M251151</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123543"&gt;@AbhiTryingAgain&lt;/a&gt;&amp;nbsp;Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 19:43:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIFI-nifi-Extract-content-from-json-array-into-separate/m-p/401423#M251151</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2025-02-03T19:43:03Z</dc:date>
    </item>
  </channel>
</rss>

