<?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: Create a document with loops in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354990#M120840</link>
    <description>&lt;P&gt;Hi, in this scenario I manipulate the String to make multiple loop in tWriteJsonField, I hijack the component wich is not made to work like that, so you have to make string manipulation to get what you want,&lt;/P&gt;&lt;P&gt;as you can see it's not very difficult and don't require a lot of components.&lt;/P&gt;&lt;P&gt;you can do a really complex regular expression to delete the null values but in your case tReplace will do the work easily.&lt;/P&gt;&lt;P&gt;Rest Webservice are usaly made to work with JSON , but you can also return a xml response.&lt;/P&gt;&lt;P&gt;In tRestClient you Have globalMap : ((java.util.Map&amp;lt;String,java.util.List&amp;lt;String&amp;gt;&amp;gt;)globalMap.get("tRESTClient_1_HEADERS")) wich permit you to know the header of your request , so you can drive your response in Json  or xml  depending of the value application/xml or application/json , but you have to make a flow that transform your database input into an xml file for the xml part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jul 2021 07:11:07 GMT</pubDate>
    <dc:creator>gjeremy1617088143</dc:creator>
    <dc:date>2021-07-16T07:11:07Z</dc:date>
    <item>
      <title>Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354986#M120836</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's imagine we have these fictional data in a tFixedFlow (but this will actually come from a database) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000Ghkj8AAB.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155856i0F6BD5A739BBF96E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000Ghkj8AAB.png" alt="0695b00000Ghkj8AAB.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create an API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We could get this JSON file by default, converting the data lines returned by the database / tfixedflow here into a document : &lt;B&gt;LET'S NAME IT CONTENT 1&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Alpha",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Small Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Water"&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Alpha",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Medium Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Air"&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Bravo",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Big Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Ice"&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Alpha",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Small Cyclone",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Poison"&lt;/P&gt;&lt;P&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;However, I wonder if it's possible to get this json content : LET'S NAME IT CONTENT 2&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Alpha",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": ["Small Fire", "Medium Fire", "Small Cyclone"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": ["Water", "Air", "Poison"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Bravo",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Big Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Ice"&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Or even this one : LET'S NAME IT CONTENT 3&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Alpha",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Small Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Medium Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Small Cyclone",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Water",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Air",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Poison",&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"ID_Ent": 2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Name": "Bravo",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Skill": "Big Fire",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Weakness": "Ice"&lt;/P&gt;&lt;P&gt;&amp;nbsp;},&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to generate CONTENT 2 ? What about CONTENT 3 ? How ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:57:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354986#M120836</guid>
      <dc:creator>Alpha549</dc:creator>
      <dc:date>2024-11-15T23:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354987#M120837</link>
      <description>&lt;P&gt;Hi , here the best I can get with few components :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"Id_ent":1,"Name":"Alpha","Skill":["Small Fire","Medium Fire","Small Cyclone"],"Weakness":["Water","Air","Poison"]},{"Id_ent":2,"Name":"Bravo","Skill":["Big Fire"],"Weakness":["Ice"]}]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I add a new column named CUMUL with X as value in tfixedflowInput&lt;/P&gt;&lt;P&gt;in the schema i set Id_Ent as an Int and everything else as String&lt;/P&gt;&lt;P&gt;then i use a tSortRow and I sort Id_ent by num asc&lt;/P&gt;&lt;P&gt;then I use a tDenormalize I Set Skill and Weakness as column to denormalize with "\",\"" as Delimiter and Merge same value check&lt;/P&gt;&lt;P&gt;then in a tWrite JSONField :&lt;/P&gt;&lt;P&gt;JSON TREE &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rootTag&lt;/P&gt;&lt;P&gt;sub element of rootTag root as loop element&lt;/P&gt;&lt;P&gt;sub element of root :ID_Ent&lt;/P&gt;&lt;P&gt;sub element of root Name&lt;/P&gt;&lt;P&gt;Sub element of root Skill with attribute class static value array&lt;/P&gt;&lt;P&gt;Sub element of root Weakness with attribute class static value array&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and a group by the CUMUL column on the component options and remove root node checked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then i use a tReplace Search "\\" replace with "" no options checked.&lt;/P&gt;&lt;P&gt;Send me Love and Kudos&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:27:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354987#M120837</guid>
      <dc:creator>gjeremy1617088143</dc:creator>
      <dc:date>2021-07-15T14:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354988#M120838</link>
      <description>&lt;P&gt;you can do (your string).replaceAll("\\[(?=([a-zA-z \"]+\\]))","")&lt;/P&gt;&lt;P&gt;.replaceAll("(?&amp;lt;=(\\:[a-zA-z \"]{1,100}))\\]","")&lt;/P&gt;&lt;P&gt;to replace all [ and ] when you have unique value&lt;/P&gt;&lt;P&gt;&amp;nbsp;of course it's only work with letters and space in the value&lt;/P&gt;&lt;P&gt;here the result :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"Id_ent":1,"Name":"Alpha","Skill":["Small Fire","Medium Fire","Small Cyclone"],"Weakness":["Water","Air","Poison"]},{"Id_ent":2,"Name":"Bravo","Skill":"Big Fire","Weakness":"Ice"}]&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 15:00:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354988#M120838</guid>
      <dc:creator>gjeremy1617088143</dc:creator>
      <dc:date>2021-07-15T15:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354989#M120839</link>
      <description>&lt;P&gt;Thanks a lot ! It worked fine !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have more questions :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) If I erase a value in the tFixedFlow (for example a weakness), is get "null" in the weakness values :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000GhvLBAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129343iA92DB2780F1B0328/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000GhvLBAAZ.png" alt="0695b00000GhvLBAAZ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same if I use an empty string, I get "" instead of "null".&lt;/P&gt;&lt;P&gt;Is there a way to simply delete this value from the [ ... ]?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT : I did it using a tReplace, replacing :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;",\"null\"]" by "]"&lt;/LI&gt;&lt;LI&gt;",\"null\"," by ","&lt;/LI&gt;&lt;LI&gt;"[\"null\"," by "["&lt;/LI&gt;&lt;LI&gt;"[\"null\"]" by "[]"&lt;/LI&gt;&lt;LI&gt;Idem for empty string&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;However, is there another way (just to have several methods in my toolbox) ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) If I configure my tREST_RESPONSE on String, the result is fine. Using a tREST_RESPONSE, Is it possible to return an XML or a JSON ? I think that here we made the choice of returning a json string in any case but is there a way to allow the client to choose what it wants ? For example if the Accept client header is application/xml or application/json ?&lt;/P&gt;&lt;P&gt;In any case, if not possible, I could let my tREST_RESPONSE configuration on String, knowing that this string is a json.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 20:10:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354989#M120839</guid>
      <dc:creator>Alpha549</dc:creator>
      <dc:date>2021-07-15T20:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354990#M120840</link>
      <description>&lt;P&gt;Hi, in this scenario I manipulate the String to make multiple loop in tWriteJsonField, I hijack the component wich is not made to work like that, so you have to make string manipulation to get what you want,&lt;/P&gt;&lt;P&gt;as you can see it's not very difficult and don't require a lot of components.&lt;/P&gt;&lt;P&gt;you can do a really complex regular expression to delete the null values but in your case tReplace will do the work easily.&lt;/P&gt;&lt;P&gt;Rest Webservice are usaly made to work with JSON , but you can also return a xml response.&lt;/P&gt;&lt;P&gt;In tRestClient you Have globalMap : ((java.util.Map&amp;lt;String,java.util.List&amp;lt;String&amp;gt;&amp;gt;)globalMap.get("tRESTClient_1_HEADERS")) wich permit you to know the header of your request , so you can drive your response in Json  or xml  depending of the value application/xml or application/json , but you have to make a flow that transform your database input into an xml file for the xml part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:11:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354990#M120840</guid>
      <dc:creator>gjeremy1617088143</dc:creator>
      <dc:date>2021-07-16T07:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354991#M120841</link>
      <description>&lt;P&gt;Thanks a LOT for your help &lt;A href="https://community.talend.com/s/profile/0055b00000Ll14kAAB" alt="https://community.talend.com/s/profile/0055b00000Ll14kAAB" target="_blank"&gt;gjeremy1617088143&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You perfectly responded to my questions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See you soon maybe !&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 13:48:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354991#M120841</guid>
      <dc:creator>Alpha549</dc:creator>
      <dc:date>2021-07-16T13:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create a document with loops</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354992#M120842</link>
      <description>&lt;P&gt;I Hope it's real data, Ultima was my favorite materia ;).&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 14:35:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-a-document-with-loops/m-p/2354992#M120842</guid>
      <dc:creator>gjeremy1617088143</dc:creator>
      <dc:date>2021-07-16T14:35:23Z</dc:date>
    </item>
  </channel>
</rss>

