<?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>topic Divide JSON into blocks when key's value changes in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Divide-JSON-into-blocks-when-key-s-value-changes/m-p/2284411#M58108</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I receive JSON files having thousands of lines and I want to divide it into 'n' blocks having the same key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance let's say I have the following input data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[{key:A, key2=abc}; {key:A, key2=abe},
{key:B, key2=zyw}, {key:B, key2=123},
{key:C, key2=fgh}]&lt;/PRE&gt;&lt;P&gt;I want to split the above into 3 blocks: A, B, C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using tFlowToIterate but I can't find the Talend's way to split on a condition and then process the end of the job for each split...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone indicate a way? Thx!&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>Sat, 16 Nov 2024 04:26:33 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-16T04:26:33Z</dc:date>
    <item>
      <title>Divide JSON into blocks when key's value changes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Divide-JSON-into-blocks-when-key-s-value-changes/m-p/2284411#M58108</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I receive JSON files having thousands of lines and I want to divide it into 'n' blocks having the same key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance let's say I have the following input data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[{key:A, key2=abc}; {key:A, key2=abe},
{key:B, key2=zyw}, {key:B, key2=123},
{key:C, key2=fgh}]&lt;/PRE&gt;&lt;P&gt;I want to split the above into 3 blocks: A, B, C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using tFlowToIterate but I can't find the Talend's way to split on a condition and then process the end of the job for each split...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone indicate a way? Thx!&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>Sat, 16 Nov 2024 04:26:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Divide-JSON-into-blocks-when-key-s-value-changes/m-p/2284411#M58108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T04:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Divide JSON into blocks when key's value changes</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Divide-JSON-into-blocks-when-key-s-value-changes/m-p/2284412#M58109</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since, I think, your key is random, you can't use XPath to extract blocks.&lt;/P&gt;
&lt;P&gt;Given that, you should split your JSON into 5 lines like this :&lt;/P&gt;
&lt;PRE&gt;{key:A, key2=abc}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;using a tNormalize components on the JSON String.&lt;/P&gt;
&lt;P&gt;Then you extract, and "tag" your line with the key and use a tAggregateRow to build a List.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using .toString() method on the list will output all data, separated by a comma. Feel free to adapt the mechanism.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 19:47:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Divide-JSON-into-blocks-when-key-s-value-changes/m-p/2284412#M58109</guid>
      <dc:creator>rmartin2</dc:creator>
      <dc:date>2019-10-08T19:47:02Z</dc:date>
    </item>
  </channel>
</rss>

