<?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 How to parse Dictionary with talend? in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-parse-Dictionary-with-talend/m-p/2238528#M26604</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to loop the dictionary as below&lt;/P&gt;
&lt;P&gt;{"Departments":{"aaa":111,"bbb":222,"ccc":333,"ddd":444,"eee":555,"fff":666,"ggg":777,"hhh":888}}&lt;/P&gt;
&lt;P&gt;with tfileinputjson and with XPath,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my scenario I have N number of keys, how can I store all the keys in column 1 and values in column two without using custom component.&lt;/P&gt;
&lt;P&gt;Please find the pic of my tfileinputjson component details.&lt;/P&gt;
&lt;P&gt;PFA&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2019 14:41:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-11-05T14:41:04Z</dc:date>
    <item>
      <title>How to parse Dictionary with talend?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-parse-Dictionary-with-talend/m-p/2238528#M26604</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to loop the dictionary as below&lt;/P&gt;
&lt;P&gt;{"Departments":{"aaa":111,"bbb":222,"ccc":333,"ddd":444,"eee":555,"fff":666,"ggg":777,"hhh":888}}&lt;/P&gt;
&lt;P&gt;with tfileinputjson and with XPath,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my scenario I have N number of keys, how can I store all the keys in column 1 and values in column two without using custom component.&lt;/P&gt;
&lt;P&gt;Please find the pic of my tfileinputjson component details.&lt;/P&gt;
&lt;P&gt;PFA&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 14:41:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-parse-Dictionary-with-talend/m-p/2238528#M26604</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-05T14:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse Dictionary with talend?</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-parse-Dictionary-with-talend/m-p/2238529#M26605</link>
      <description>&lt;P&gt;Unfortunately unknown keys are a bit of a challenge with Talend JSON components. However, you can get around this using Java.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Take a look at the code I have used in this question (&lt;A href="https://community.qlik.com/s/feed/0D53p00007vCoccCAC#M98452" target="_blank"&gt;https://community.talend.com/t5/Design-and-Development/how-can-i-parsing-json-array-and-create-the-table-on-sql-server/m-p/161454#M98452&lt;/A&gt;). You can use that same code, with a Job that looks like this....&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2019-11-06 at 16.35.32.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M8U6.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/131815iA38581544B1DB307/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M8U6.png" alt="0683p000009M8U6.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;The tFixedFlowInput_1 is where I am beginning, but you can change this if required. It simply provides the JSON. I extract the "Description" entity using the tExtractJSONFields_1 component. I have configured it like this...&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2019-11-06 at 16.35.54.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M8Td.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/143407iE72859C9C53CB56A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M8Td.png" alt="0683p000009M8Td.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;In the tJavaFlex component, I am using the routine method I described in the post I have linked to above. In my example the routine is called TestRoutines and my method is called getSubJSON.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;Main Code&lt;/STRONG&gt;&lt;/P&gt; 
&lt;PRE&gt;java.util.ArrayList&amp;lt;String&amp;gt; al = routines.TestRoutines.getSubJSON(row2.Description);
java.util.Iterator&amp;lt;String&amp;gt; it = al.iterator();

while(it.hasNext()){
	System.out.println(it.next());
}&lt;/PRE&gt; 
&lt;P&gt;I am simply iterating this out to the System.out. You will need to decide what you do with the data from there.&lt;/P&gt; 
&lt;P&gt;In the output window I get the following using your JSON....&lt;/P&gt; 
&lt;PRE&gt;[statistics] connecting to socket on port 4036
[statistics] connected
{"aaa":111}
{"ccc":333}
{"bbb":222}
{"eee":555}
{"ddd":444}
{"ggg":777}
{"fff":666}
{"hhh":888}
[statistics] disconnected&lt;/PRE&gt; 
&lt;P&gt;You can get to the key and value using simple String manipulation from here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 16:45:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-parse-Dictionary-with-talend/m-p/2238529#M26605</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-06T16:45:07Z</dc:date>
    </item>
  </channel>
</rss>

