<?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: tRestResponse : return a JSON or XML object in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tRestResponse-return-a-JSON-or-XML-object/m-p/2297552#M70115</link>
    <description>&lt;P&gt;You're essentially posting a String into an XML element. You cannot mix like this. What is the full JSON structure you require?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you need to do here is to build the complete JSON structure and change the Return Body Type of the tRestResponse to String. Then, remove the tXMLMap and simply pass the JSON String (completed) to the body output (which will now be set to String). &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should be pointed out that your JSON array has some errors. I believe it should be structured like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{"root":{"student":{"Person":[{"lastname":"A",&amp;nbsp;"firstname":"B",&amp;nbsp;"age":20,&amp;nbsp;"listeRoles":[&amp;nbsp;"Etudiant",&amp;nbsp;"Test"]}]}}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll need to adjust your routine to enable quotes. The above (hardcoded) in Java would be created like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String myValue = "{&amp;nbsp;&amp;nbsp;\"root\":{ \"student\":{ \"Person\":[&amp;nbsp;{&amp;nbsp;\"lastname\":\"A\", \"firstname\":\"B\",&amp;nbsp;\"age\":20,&amp;nbsp;\"listeRoles\":[&amp;nbsp;\"Etudiant\", \"Test\" ] } ] } }}";&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2022 01:01:28 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-04-27T01:01:28Z</dc:date>
    <item>
      <title>tRestResponse : return a JSON or XML object</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRestResponse-return-a-JSON-or-XML-object/m-p/2297551#M70114</link>
      <description>&lt;P&gt;Hello everyone, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simple class (as a routine file) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtMbAAL.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/134338i31B4DE7316619068/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtMbAAL.png" alt="0695b00000QDtMbAAL.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simple REST API job :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtNFAA1.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/128808iBC45F7377BB61326/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtNFAA1.png" alt="0695b00000QDtNFAA1.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtNtAAL.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/134523i3646EA4C5EF56F78/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtNtAAL.png" alt="0695b00000QDtNtAAL.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtOXAA1.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/150907i248611967183EA1A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtOXAA1.png" alt="0695b00000QDtOXAA1.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtOmAAL.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146883i378B5CA9E4113054/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtOmAAL.png" alt="0695b00000QDtOmAAL.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000QDtPLAA1.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155897i5E0DB9CB99EC9A8A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtPLAA1.png" alt="0695b00000QDtPLAA1.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use the API, I get 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="0695b00000QDtPkAAL.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/141094i0CC2DF2A4F168AAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000QDtPkAAL.png" alt="0695b00000QDtPkAAL.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Student is displayed a its toString method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;I would like to know if it's possible to get a JSON representation of student ?&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;I've thought about a solution : use Google GSON library to convert an object into a JSON string, and return this string instead of the object (student like here).&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Can you confirm it's a confortable solution ?&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you everyone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:00:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRestResponse-return-a-JSON-or-XML-object/m-p/2297551#M70114</guid>
      <dc:creator>Alpha549</dc:creator>
      <dc:date>2024-11-15T23:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: tRestResponse : return a JSON or XML object</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRestResponse-return-a-JSON-or-XML-object/m-p/2297552#M70115</link>
      <description>&lt;P&gt;You're essentially posting a String into an XML element. You cannot mix like this. What is the full JSON structure you require?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you need to do here is to build the complete JSON structure and change the Return Body Type of the tRestResponse to String. Then, remove the tXMLMap and simply pass the JSON String (completed) to the body output (which will now be set to String). &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should be pointed out that your JSON array has some errors. I believe it should be structured like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{"root":{"student":{"Person":[{"lastname":"A",&amp;nbsp;"firstname":"B",&amp;nbsp;"age":20,&amp;nbsp;"listeRoles":[&amp;nbsp;"Etudiant",&amp;nbsp;"Test"]}]}}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll need to adjust your routine to enable quotes. The above (hardcoded) in Java would be created like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String myValue = "{&amp;nbsp;&amp;nbsp;\"root\":{ \"student\":{ \"Person\":[&amp;nbsp;{&amp;nbsp;\"lastname\":\"A\", \"firstname\":\"B\",&amp;nbsp;\"age\":20,&amp;nbsp;\"listeRoles\":[&amp;nbsp;\"Etudiant\", \"Test\" ] } ] } }}";&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 01:01:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRestResponse-return-a-JSON-or-XML-object/m-p/2297552#M70115</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-27T01:01:28Z</dc:date>
    </item>
  </channel>
</rss>

