<?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: [resolved] TOS REST client iteratating and parsing in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302635#M74595</link>
    <description>Hi
&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;I have yet been able to get the tRest component to return anything other than a string which I can't figure out how to process.&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;After tRest, you can use a tExtractJsonField to extract the value from the response string, if the response format is not fixed, parse the response on a tJavaRow first, and then use different tExtractJsonField with different mapping base on the parse result to extract the value, for example:
&lt;BR /&gt;tRest--main--tJavaRow--runIf_1--tFixedFlowInput--main--tExtractJsonField--main--tLogRow
&lt;BR /&gt; --runIf_2--tFixedFlowInput--main--tExtractJsonField--main--tLogRow
&lt;BR /&gt;Shong</description>
    <pubDate>Thu, 04 Jul 2013 02:36:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-07-04T02:36:21Z</dc:date>
    <item>
      <title>[resolved] TOS REST client iteratating and parsing</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302634#M74594</link>
      <description>Hello all! 
&lt;BR /&gt;I have recently been demoing talend as an ETL tool (currently SAP Data Services and Informatica developer). I am having some issues with a RESTful WS that returns only JSON data. The data returned is paged, so I need to be able to iterate through the rest calls until a key/value json field returns false. I have a Boolean flag in the globalmap that holds this value, but I can only attach a loop to the tRest component and not the tRESTClient component. I have yet been able to get the tRest component to return anything other than a string which I can't figure out how to process. 
&lt;BR /&gt;The other issue I have is that this particular CRM's WS is not particularly defined well. For instance, the main element that I will loop through is data. It has a child element that can either be a parent node or just an element. For example: 
&lt;BR /&gt;It can look like this: 
&lt;BR /&gt; 
&lt;PRE&gt;"data" : &lt;/PRE&gt; 
&lt;BR /&gt;or this: 
&lt;BR /&gt; 
&lt;PRE&gt;"data" : &lt;/PRE&gt; 
&lt;BR /&gt;Not quite sure how to best process this. In tRESTClient, I either have to define something as an element or a node, it can't be both. 
&lt;BR /&gt;Any idea? 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Scott</description>
      <pubDate>Mon, 01 Jul 2013 22:21:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302634#M74594</guid>
      <dc:creator>TXAggie00</dc:creator>
      <dc:date>2013-07-01T22:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] TOS REST client iteratating and parsing</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302635#M74595</link>
      <description>Hi
&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;I have yet been able to get the tRest component to return anything other than a string which I can't figure out how to process.&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;After tRest, you can use a tExtractJsonField to extract the value from the response string, if the response format is not fixed, parse the response on a tJavaRow first, and then use different tExtractJsonField with different mapping base on the parse result to extract the value, for example:
&lt;BR /&gt;tRest--main--tJavaRow--runIf_1--tFixedFlowInput--main--tExtractJsonField--main--tLogRow
&lt;BR /&gt; --runIf_2--tFixedFlowInput--main--tExtractJsonField--main--tLogRow
&lt;BR /&gt;Shong</description>
      <pubDate>Thu, 04 Jul 2013 02:36:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302635#M74595</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-04T02:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] TOS REST client iteratating and parsing</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302636#M74596</link>
      <description>&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;After tRest, you can use a tExtractJsonField to extract the value from the response string, if the response format is not fixed, parse the response on a tJavaRow first, and then use different tExtractJsonField with different mapping base on the parse result to extract the value...&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Thanks for the reply Shong. I found a solution using the custom component tParseJSON. What I ended up doing for the elements that could also be nodes, was brought them in as Objects and then wrote the following custom code that parses the string passed in as that object: 
&lt;BR /&gt; 
&lt;PRE&gt;    public static Integer getJSONValue(Object str) {&lt;BR /&gt;    	Integer myNullInt = null;&lt;BR /&gt;    	if(str == null || str.toString().trim().length()==0) {&lt;BR /&gt;    		return myNullInt;&lt;BR /&gt;    	}&lt;BR /&gt;    	String object = str.toString().trim();&lt;BR /&gt;    	int id;&lt;BR /&gt;    	try {&lt;BR /&gt;    		id = Integer.parseInt(object);&lt;BR /&gt;    		return id;&lt;BR /&gt;    	} catch(Exception e) {&lt;BR /&gt;    		String[] jsonArr = object.split(",");&lt;BR /&gt;    		for(int i=0;i&amp;lt;jsonArr.length; i++) {&lt;BR /&gt;    			if(jsonArr&lt;I&gt;.contains("\"value\"")) {&lt;BR /&gt;    				String[] idVal = jsonArr&lt;I&gt;.split(":");&lt;BR /&gt;    				idVal = idVal.replace('"', ' ').replace('}', ' ').replace('{', ' ').trim();&lt;BR /&gt;    				try {&lt;BR /&gt;    					id = Integer.parseInt(idVal);&lt;BR /&gt;    					return id;&lt;BR /&gt;    				} catch (Exception ex) {&lt;BR /&gt;    					return myNullInt;&lt;BR /&gt;    				}&lt;BR /&gt;    			}&lt;BR /&gt;    		}&lt;BR /&gt;    		return myNullInt;&lt;BR /&gt;    	}&lt;BR /&gt;    }&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; 
&lt;BR /&gt;I attached the screenshot of the flow in case it helps anyone else. tParseJSON was found at 
&lt;A href="https://github.com/ijokarumawak/tParseJSON" rel="nofollow noopener noreferrer"&gt;https://github.com/ijokarumawak/tParseJSON&lt;/A&gt; 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Scott 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MEbZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/138541iA6655F9F7FA3F8BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MEbZ.png" alt="0683p000009MEbZ.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Fri, 05 Jul 2013 15:57:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-TOS-REST-client-iteratating-and-parsing/m-p/2302636#M74596</guid>
      <dc:creator>TXAggie00</dc:creator>
      <dc:date>2013-07-05T15:57:34Z</dc:date>
    </item>
  </channel>
</rss>

