<?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 [resolved] JSON Payload - Validate in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332206#M101110</link>
    <description>I have a simple webservice setup.
&lt;BR /&gt;
&lt;BR /&gt;tRestRequest --&amp;gt; tExtractJSONFields --&amp;gt; my processing code --&amp;gt; tXMLMap --&amp;gt; tRestResponse
&lt;BR /&gt;
&lt;BR /&gt;It works perfectly fine. However, one missing chunk is how to validate the input JSON payload (POST in my case) and send back an error HTTP code like 400 back to the client?
&lt;BR /&gt;
&lt;BR /&gt;Is there any direct way to validate the JSON document being sent which has all the relevant fields? What are the best practices which one can follow to design the job?</description>
    <pubDate>Sat, 16 Nov 2024 10:25:26 GMT</pubDate>
    <dc:creator>root</dc:creator>
    <dc:date>2024-11-16T10:25:26Z</dc:date>
    <item>
      <title>[resolved] JSON Payload - Validate</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332206#M101110</link>
      <description>I have a simple webservice setup.
&lt;BR /&gt;
&lt;BR /&gt;tRestRequest --&amp;gt; tExtractJSONFields --&amp;gt; my processing code --&amp;gt; tXMLMap --&amp;gt; tRestResponse
&lt;BR /&gt;
&lt;BR /&gt;It works perfectly fine. However, one missing chunk is how to validate the input JSON payload (POST in my case) and send back an error HTTP code like 400 back to the client?
&lt;BR /&gt;
&lt;BR /&gt;Is there any direct way to validate the JSON document being sent which has all the relevant fields? What are the best practices which one can follow to design the job?</description>
      <pubDate>Sat, 16 Nov 2024 10:25:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332206#M101110</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2024-11-16T10:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] JSON Payload - Validate</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332207#M101111</link>
      <description>Hi
&lt;BR /&gt;Here is my idea: validate all of fields on a tJavaRow and then trigger different processing based on the validation result, eg:
&lt;BR /&gt;
&lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;tRestRequest --&amp;gt; tExtractJSONFields --&amp;gt;main--tJavaRow--runIf1---tfixedFlowInput--main--my processing code...tRestResponse1&lt;/FONT&gt;&lt;/FONT&gt;
&lt;BR /&gt;
&lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;--runIf2---tfixedFlowInput--main--tXMLMap--...tRestResponse2&lt;/FONT&gt;&lt;/FONT&gt;
&lt;BR /&gt;
&lt;BR /&gt;on tJavaRow:
&lt;BR /&gt;if(..multiple validation condition..){
&lt;BR /&gt;global.put("isValid",true);
&lt;BR /&gt;context.columnName=input_row.columName;
&lt;BR /&gt;context.otherColumnName=input_row.otherColumnName;
&lt;BR /&gt;}else{
&lt;BR /&gt;global.put("isValid",false);
&lt;BR /&gt;}
&lt;BR /&gt;
&lt;BR /&gt;set the condition of runIf1 as:
&lt;BR /&gt;(Boolean)globalMap.get("isValid")
&lt;BR /&gt;
&lt;BR /&gt;set the condition of runIf2 as:
&lt;BR /&gt;!(Boolean)globalMap.get("isValid")
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;tfixedFlowInput: generate the current row with context variables.&lt;/FONT&gt;&lt;/FONT&gt;
&lt;BR /&gt;
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Wed, 31 Aug 2016 13:36:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332207#M101111</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-31T13:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] JSON Payload - Validate</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332208#M101112</link>
      <description>&lt;BLOCKQUOTE&gt;
  shong wrote: 
 &lt;BR /&gt;Hi 
 &lt;BR /&gt;Here is my idea: validate all of fields on a tJavaRow and then trigger different processing based on the validation result, eg: 
 &lt;BR /&gt; 
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;tRestRequest --&amp;gt; tExtractJSONFields --&amp;gt;main--tJavaRow--runIf1---tfixedFlowInput--main--my processing code...tRestResponse1&lt;/FONT&gt;&lt;/FONT&gt; 
 &lt;BR /&gt; 
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt; 
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;--runIf2---tfixedFlowInput--main--tXMLMap--...tRestResponse2&lt;/FONT&gt;&lt;/FONT&gt; 
 &lt;BR /&gt; 
 &lt;BR /&gt;on tJavaRow: 
 &lt;BR /&gt;if(..multiple validation condition..){ 
 &lt;BR /&gt;global.put("isValid",true); 
 &lt;BR /&gt;context.columnName=input_row.columName; 
 &lt;BR /&gt;context.otherColumnName=input_row.otherColumnName; 
 &lt;BR /&gt;}else{ 
 &lt;BR /&gt;global.put("isValid",false); 
 &lt;BR /&gt;} 
 &lt;BR /&gt; 
 &lt;BR /&gt;set the condition of runIf1 as: 
 &lt;BR /&gt;(Boolean)globalMap.get("isValid") 
 &lt;BR /&gt; 
 &lt;BR /&gt;set the condition of runIf2 as: 
 &lt;BR /&gt;!(Boolean)globalMap.get("isValid") 
 &lt;BR /&gt; 
 &lt;BR /&gt; 
 &lt;FONT size="2"&gt;&lt;FONT face="Verdana," helvetica=""&gt;tfixedFlowInput: generate the current row with context variables.&lt;/FONT&gt;&lt;/FONT&gt; 
 &lt;BR /&gt; 
 &lt;BR /&gt;Regards 
 &lt;BR /&gt;Shong 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;This is great. I tried, it works. I was actually expecting a way in which a JSON document could be validated directly on a schema or something... but, again, this works. Thanks.</description>
      <pubDate>Wed, 31 Aug 2016 20:36:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-JSON-Payload-Validate/m-p/2332208#M101112</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2016-08-31T20:36:57Z</dc:date>
    </item>
  </channel>
</rss>

