<?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 Create JSON from Query with tjsonDocOutput in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Create-JSON-from-Query-with-tjsonDocOutput/m-p/2203870#M4980</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt; 
&lt;P&gt;I am new to the tjsonDoc* components. I read the documentation from &lt;SPAN class="pr-md-4 f6"&gt;&lt;A href="https://github.com/jlolling" target="_blank" rel="author noopener nofollow noopener noreferrer"&gt;jlolling&lt;/A&gt; &lt;/SPAN&gt;but still not sure how to create the following json from a (one?) database query&lt;/P&gt; 
&lt;PRE&gt;{&lt;BR /&gt;  "data": {&lt;BR /&gt;    "masters": [&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "origin": "BER",&lt;BR /&gt;        "destination": "FRA",&lt;BR /&gt;        "items": 2&lt;BR /&gt;      }&lt;BR /&gt;    ],&lt;BR /&gt;    "items": [&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "item_number": "1",&lt;BR /&gt;        "item_origin": "BER"&lt;BR /&gt;      },&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "item_number": "2",&lt;BR /&gt;        "item_origin": "BER"&lt;BR /&gt;       }&lt;BR /&gt;     ]&lt;BR /&gt;   }&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Is it neccessary to query the database twice, once for master and again for child data (items)?So far I created the following:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job_1.PNG" style="width: 935px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M92T.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146123iFDD94AC699B00AE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M92T.png" alt="0683p000009M92T.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;But I get (as configured in the job) a json array with objects containing master and item data in it:&lt;/P&gt; 
&lt;PRE&gt; "masters": [
    {
  	"master_number" : "12345678912",
  	"origen" : "BER",
  	"destination" : "FRA",
  	"items" : 2
 	"item_number": "1",
        "item_origin": "BER"
    }, 
    {
  	"master_number" : "12345678912",
  	"origen" : "BER",
  	"destination" : "FRA",
  	"items" : 2
 	"item_number": "2",
        "item_origin": "BER"

    }, 
...&lt;/PRE&gt; 
&lt;P&gt;So it puts every row and corresponding columns to one new json objects. How to split it into one master and its items? I guess I should use forreign key structure?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Could someone give me a hint for the basic job structure?&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2020 12:30:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-17T12:30:29Z</dc:date>
    <item>
      <title>Create JSON from Query with tjsonDocOutput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Create-JSON-from-Query-with-tjsonDocOutput/m-p/2203870#M4980</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt; 
&lt;P&gt;I am new to the tjsonDoc* components. I read the documentation from &lt;SPAN class="pr-md-4 f6"&gt;&lt;A href="https://github.com/jlolling" target="_blank" rel="author noopener nofollow noopener noreferrer"&gt;jlolling&lt;/A&gt; &lt;/SPAN&gt;but still not sure how to create the following json from a (one?) database query&lt;/P&gt; 
&lt;PRE&gt;{&lt;BR /&gt;  "data": {&lt;BR /&gt;    "masters": [&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "origin": "BER",&lt;BR /&gt;        "destination": "FRA",&lt;BR /&gt;        "items": 2&lt;BR /&gt;      }&lt;BR /&gt;    ],&lt;BR /&gt;    "items": [&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "item_number": "1",&lt;BR /&gt;        "item_origin": "BER"&lt;BR /&gt;      },&lt;BR /&gt;      {&lt;BR /&gt;        "master_number": "12345678912",&lt;BR /&gt;        "item_number": "2",&lt;BR /&gt;        "item_origin": "BER"&lt;BR /&gt;       }&lt;BR /&gt;     ]&lt;BR /&gt;   }&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Is it neccessary to query the database twice, once for master and again for child data (items)?So far I created the following:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job_1.PNG" style="width: 935px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M92T.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146123iFDD94AC699B00AE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M92T.png" alt="0683p000009M92T.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;But I get (as configured in the job) a json array with objects containing master and item data in it:&lt;/P&gt; 
&lt;PRE&gt; "masters": [
    {
  	"master_number" : "12345678912",
  	"origen" : "BER",
  	"destination" : "FRA",
  	"items" : 2
 	"item_number": "1",
        "item_origin": "BER"
    }, 
    {
  	"master_number" : "12345678912",
  	"origen" : "BER",
  	"destination" : "FRA",
  	"items" : 2
 	"item_number": "2",
        "item_origin": "BER"

    }, 
...&lt;/PRE&gt; 
&lt;P&gt;So it puts every row and corresponding columns to one new json objects. How to split it into one master and its items? I guess I should use forreign key structure?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Could someone give me a hint for the basic job structure?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:30:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Create-JSON-from-Query-with-tjsonDocOutput/m-p/2203870#M4980</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-17T12:30:29Z</dc:date>
    </item>
  </channel>
</rss>

