<?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: Conditional JSON Structure in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329788#M98945</link>
    <description>&lt;P&gt;if you are a Java developer, I would like the way 2 mentioned in your post, write a user function to parse the JSON string and remove the fields whose value is zero or null, and the function return a JSON string. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Mar 2021 06:03:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-03-05T06:03:44Z</dc:date>
    <item>
      <title>Conditional JSON Structure</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329785#M98942</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm struggling to get a "dynamic" json structure, depending on some input field value :&lt;/P&gt;&lt;P&gt;Ex :&lt;/P&gt;&lt;P&gt;{"field1" : "value1",&lt;/P&gt;&lt;P&gt;"field2" : value2,&lt;/P&gt;&lt;P&gt;"field3": value3}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field2 is a numeric =&amp;gt; when i get a zero or null value, i want to remove this field from the json structure, like this :&lt;/P&gt;&lt;P&gt;{"field1" : "value1", "field3": "value3"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1- At first i ve used a tmap to test field 2 value and output accordingly  to 2 twritejsonfield with 2 different structures&lt;/P&gt;&lt;P&gt;InputData---&amp;gt;Tmap (test value2) ----&amp;gt;tWriteJsonField1 (with structure : field1,field2,field3)&lt;/P&gt;&lt;P&gt;                                                    -----&amp;gt;tWriteJsonField2 (with structure : field1,field3 , when value2 is null or zero)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem is that i have a big json structure,  with multiple numeric fields that need to be tested and removed if they're null.&lt;/P&gt;&lt;P&gt;I don't want to create dozens "static" json structures in multiple tWriteJsonFields, to manage my bad data quality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 - My second solution was to create in a tJavaFlow the Json String , and adding "field2":value2 when row.value2!=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not satisfied with these solutions&lt;/P&gt;&lt;P&gt;Is there a way to use a "json object" in tJavaRow for exemple to build dynamically the structure and add the field only if conditions are fullfilled ?&lt;/P&gt;&lt;P&gt;Or a more simple solution with Talend native or user components that allows to add conditionally an attribute to the Json Tree&lt;/P&gt;&lt;P&gt;It might be very simple but i spent really too much time looking for the good way to do this and didn't succeed !&lt;/P&gt;&lt;P&gt;Million thanks if you can help me!&lt;/P&gt;&lt;P&gt;Fred&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;</description>
      <pubDate>Wed, 03 Mar 2021 22:07:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329785#M98942</guid>
      <dc:creator>Mynameisfred_64</dc:creator>
      <dc:date>2021-03-03T22:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional JSON Structure</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329786#M98943</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Unfortunately, there is no such component to check and build the JSON String dynamically. &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;</description>
      <pubDate>Thu, 04 Mar 2021 04:06:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329786#M98943</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-04T04:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional JSON Structure</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329787#M98944</link>
      <description>&lt;P&gt;Thanks Shong, any idea on how to achieve this without dedicated components ?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 13:35:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329787#M98944</guid>
      <dc:creator>Mynameisfred_64</dc:creator>
      <dc:date>2021-03-04T13:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional JSON Structure</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329788#M98945</link>
      <description>&lt;P&gt;if you are a Java developer, I would like the way 2 mentioned in your post, write a user function to parse the JSON string and remove the fields whose value is zero or null, and the function return a JSON string. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 06:03:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Conditional-JSON-Structure/m-p/2329788#M98945</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-05T06:03:44Z</dc:date>
    </item>
  </channel>
</rss>

