<?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 Re: how to create a collection of JSON objects in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/how-to-create-a-collection-of-JSON-objects/m-p/2322163#M92131</link>
    <description>&lt;BLOCKQUOTE&gt;
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;When I turn on the output of the last tExtractJSONField in a tLog, the codes and names of all the cities at once they are printed. If I change the tLog for a tFileOutputJSON, the final file contains only the last iteration called cities.&lt;/FONT&gt;&lt;/FONT&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;
&lt;BR /&gt;You are using tFlowToIterate to iterate each record, it will always generate a new file for each record. To fix it, use a tUnite to merge all the records before writing them to a file. eg:
&lt;BR /&gt;...tExtractJSONFields-tUnite-main--tFileOutputJSON
&lt;BR /&gt;
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
    <pubDate>Sun, 28 Aug 2016 10:44:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-08-28T10:44:35Z</dc:date>
    <item>
      <title>how to create a collection of JSON objects</title>
      <link>https://community.qlik.com/t5/Talend-Studio/how-to-create-a-collection-of-JSON-objects/m-p/2322162#M92130</link>
      <description>I need to create collections of JSON objects from REST requests (see post Talend - URI based on values obtained from a list). A webservice provides a collection of agencies in the following format:
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;PRE&gt;{ "COD_AGENCIA":"521800300", "NAME":"AGENCIA01"},&lt;BR /&gt;{ "COD_AGENCIA":"521999999", "NAME":"AGENCIA02"},&lt;BR /&gt;...&lt;BR /&gt;(20 other values)&lt;BR /&gt;...&lt;BR /&gt;&lt;/PRE&gt;
&lt;BR /&gt;
&lt;BR /&gt;Another webservice, from an agency code, provides the cities related to this agency, in the following format:
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;PRE&gt;{"COD_MUN":"5202155","NOME_MUN":"CITY01"},&lt;BR /&gt;{"COD_MUN":"5202502","NOME_MUN":"CITY02"},&lt;BR /&gt;...&lt;BR /&gt;&lt;/PRE&gt;
&lt;BR /&gt;
&lt;BR /&gt;I created a job that gets the agency relationship, and through a tFlowToIterate, I call multiple requests through a tRest, varying the agency code. My job is attached below.
&lt;BR /&gt;
&lt;BR /&gt;When I turn on the output of the last tExtractJSONField in a tLog, the codes and names of all the cities at once they are printed. If I change the tLog for a tFileOutputJSON, the final file contains only the last iteration called cities.
&lt;BR /&gt;
&lt;BR /&gt;What I need to change to be able to generate in a single job multiple JSON objects in the following format:
&lt;BR /&gt;
&lt;PRE&gt;{"COD_AGENCIA":"521800300",&lt;BR /&gt;&amp;nbsp;"NAME":"AGENCIA01",&lt;BR /&gt;&amp;nbsp;"CIDADES":[{"COD_MUN":"5202155","NOME_MUN":"CITY01"},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {"COD_MUN":"5202502","NOME_MUN":"CITY02"}&lt;BR /&gt;&amp;nbsp; ]&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{"COD_AGENCIA":"521999999",&lt;BR /&gt;&amp;nbsp;"NAME":"AGENCIA02",&lt;BR /&gt;&amp;nbsp;"CIDADES":[{"COD_MUN":"5244887","NOME_MUN":"CITY03"},&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {"COD_MUN":"5254522","NOME_MUN":"CITY04"}&lt;BR /&gt;&amp;nbsp; ]&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt;
&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MFZE.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157113i9DB2348EAF0E806C/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MFZE.png" alt="0683p000009MFZE.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Sat, 16 Nov 2024 10:27:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/how-to-create-a-collection-of-JSON-objects/m-p/2322162#M92130</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T10:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a collection of JSON objects</title>
      <link>https://community.qlik.com/t5/Talend-Studio/how-to-create-a-collection-of-JSON-objects/m-p/2322163#M92131</link>
      <description>&lt;BLOCKQUOTE&gt;
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;When I turn on the output of the last tExtractJSONField in a tLog, the codes and names of all the cities at once they are printed. If I change the tLog for a tFileOutputJSON, the final file contains only the last iteration called cities.&lt;/FONT&gt;&lt;/FONT&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;
&lt;BR /&gt;You are using tFlowToIterate to iterate each record, it will always generate a new file for each record. To fix it, use a tUnite to merge all the records before writing them to a file. eg:
&lt;BR /&gt;...tExtractJSONFields-tUnite-main--tFileOutputJSON
&lt;BR /&gt;
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Sun, 28 Aug 2016 10:44:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/how-to-create-a-collection-of-JSON-objects/m-p/2322163#M92131</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-28T10:44:35Z</dc:date>
    </item>
  </channel>
</rss>

