<?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 extract JSON only if tRest provides data in jsonpath in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341245#M109217</link>
    <description>&lt;P&gt;in case of success the json looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;	"itemgroup": [&lt;/P&gt;&lt;P&gt; "item1": {&lt;/P&gt;&lt;P&gt; "name": "item1",&lt;/P&gt;&lt;P&gt; "qty": 5&lt;/P&gt;&lt;P&gt; },&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; "item2": {&lt;/P&gt;&lt;P&gt; "name": "item2",&lt;/P&gt;&lt;P&gt; "qty": 17&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;in case of an error it looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"error":&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"text":&amp;nbsp;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Something went wrong"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that in case of error the node 'itemgroup' never is returned from the server and this causes the component to die .&lt;/P&gt;&lt;P&gt;I cannot us the tDie component to catch the error because in my job I have a global tLogCatcher with sends an eMail in case of error.&lt;/P&gt;&lt;P&gt;And especially the error of tExtractJsonFields I want to handle in a different way like e.g. put some error message in a database, but only in case of 'itemgroup' is not returned from the server. In any other error cases of tExtractJSONfields the global tLogCatcher should handle this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for further help...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2023 10:34:53 GMT</pubDate>
    <dc:creator>mr_burns</dc:creator>
    <dc:date>2023-01-05T10:34:53Z</dc:date>
    <item>
      <title>How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341243#M109215</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a tRest and a tExtractJSONFields component like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000bFlF6AAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129995i795E8380850F0BA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000bFlF6AAK.png" alt="0695b00000bFlF6AAK.png" /&gt;&lt;/span&gt;the property "Loop Jsonpath query" of tExtractJSONFields looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"$.itemgroup[*].item"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but sometimes the arrray 'itemgroup' is not sent back from the server, becuase of e.g. an error, then I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;	&lt;I&gt;com.jayway.jsonpath.PathNotFoundException: Missing property in path $[itemgroup]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I handle this error now? The tExtractJSONFields component has to go on and should not die.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 22:13:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341243#M109215</guid>
      <dc:creator>mr_burns</dc:creator>
      <dc:date>2024-11-15T22:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341244#M109216</link>
      <description>&lt;P&gt;hello , &lt;/P&gt;&lt;P&gt;you need share your your file json&lt;/P&gt;&lt;P&gt;and the configuration de compoment tExtractJsonFileds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;according to errer,  I think of a worng configuration in compoment tExtractJsonFileds&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 10:17:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341244#M109216</guid>
      <dc:creator>zjing</dc:creator>
      <dc:date>2023-01-05T10:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341245#M109217</link>
      <description>&lt;P&gt;in case of success the json looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;	"itemgroup": [&lt;/P&gt;&lt;P&gt; "item1": {&lt;/P&gt;&lt;P&gt; "name": "item1",&lt;/P&gt;&lt;P&gt; "qty": 5&lt;/P&gt;&lt;P&gt; },&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; "item2": {&lt;/P&gt;&lt;P&gt; "name": "item2",&lt;/P&gt;&lt;P&gt; "qty": 17&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;in case of an error it looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"error":&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"text":&amp;nbsp;[&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Something went wrong"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that in case of error the node 'itemgroup' never is returned from the server and this causes the component to die .&lt;/P&gt;&lt;P&gt;I cannot us the tDie component to catch the error because in my job I have a global tLogCatcher with sends an eMail in case of error.&lt;/P&gt;&lt;P&gt;And especially the error of tExtractJsonFields I want to handle in a different way like e.g. put some error message in a database, but only in case of 'itemgroup' is not returned from the server. In any other error cases of tExtractJSONfields the global tLogCatcher should handle this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for further help...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 10:34:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341245#M109217</guid>
      <dc:creator>mr_burns</dc:creator>
      <dc:date>2023-01-05T10:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341246#M109218</link>
      <description>&lt;P&gt;Maybe you can check response string if it contains the 'itemgroup' element, if yes, extract data from response string using tExtractJsonFields, if no, send an email. &lt;/P&gt;&lt;P&gt;eg:&lt;/P&gt;&lt;P&gt;..tRest-main--&amp;gt;tJavaRow--runIf1--tFixedFlowInput--main--tExtractJsonFields&lt;/P&gt;&lt;P&gt;                                     --runIf2--tSendMail&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;on tJavaRow:&lt;/P&gt;&lt;P&gt;context.response=input_row.Body;&lt;/P&gt;&lt;P&gt;//context.response is a context variable with string type.&lt;/P&gt;&lt;P&gt;if(input_row.Body.contains("itemgroup"){&lt;/P&gt;&lt;P&gt;globalMap.put("continueExtractData",true);&lt;/P&gt;&lt;P&gt;}else{&lt;/P&gt;&lt;P&gt;globalMap.put("continueExtractData",false);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set the condition of runIf1 as:&lt;/P&gt;&lt;P&gt;(boolean)globalMap.get("continueExtractData")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set the condition of runIf1 as:&lt;/P&gt;&lt;P&gt;!(boolean)globalMap.get("continueExtractData")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tFixedFlowInput: generate the response string as input row, define one column and set its value as: context.response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 08:39:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341246#M109218</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-06T08:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341247#M109219</link>
      <description>&lt;P&gt;thanks shong,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already could help myself and found an easier way.&lt;/P&gt;&lt;P&gt;Instead using a tRest component I use a tRestClient component now.&lt;/P&gt;&lt;P&gt;tRestClient provides an extra output called 'error' to handle my errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000bFzpDAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139035iAD667A2E5B84D5F1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000bFzpDAAS.png" alt="0695b00000bFzpDAAS.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The tJavaFlex (you can use a tRavaRow or tJava component as well) is necessary to create the Body for a Post request executed by tRestClient. There is no "Http Body" property like in tRest.&lt;/P&gt;&lt;P&gt;You need to create following output fields for tJavaFlex:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000bFzq1AAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129762i427CD0E2D0329C46/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000bFzq1AAC.png" alt="0695b00000bFzq1AAC.png" /&gt;&lt;/span&gt;The Java code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String payload = "";&lt;/P&gt;&lt;P&gt;payload += "{";&lt;/P&gt;&lt;P&gt;payload += "&amp;nbsp;\"itemgroup\":\"ABC123\", ";&lt;/P&gt;&lt;P&gt;payload += "\"filter\": [\"CurrYear=2023\"]";&lt;/P&gt;&lt;P&gt;payload += "}";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;row1.string = payload;&lt;/P&gt;&lt;P&gt;row1.body = payload;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;may this helps someone with a similar problem.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 08:46:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341247#M109219</guid>
      <dc:creator>mr_burns</dc:creator>
      <dc:date>2023-01-06T08:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON only if tRest provides data in jsonpath</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341248#M109220</link>
      <description>&lt;P&gt;I have also facing the same issue.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 05:20:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-extract-JSON-only-if-tRest-provides-data-in-jsonpath/m-p/2341248#M109220</guid>
      <dc:creator>SallyStory</dc:creator>
      <dc:date>2023-02-22T05:20:53Z</dc:date>
    </item>
  </channel>
</rss>

