Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Aznrhmn_97
Contributor
Contributor

How to create nested array using tJSONDoc

Hi all, I'm new with Talend Open Studio. I have problem to create nested array using tJSONDoc component. I did the json but not in what I want. Here is what I got:

{
  "Program":"Smart A",
   "Details":{
      "smart1":[
         {
            "people":"20",
            "class":"A",
            "archive":null,
            "type":"prog_asuh",
             attributes":{
               "type":"Attribute_Field"
            }
         }
      ]
   }
}


This is what I want :

 

{
  "Program":"Smart A",
   "Details":{
      "smart1":[
         {
            "attributes":{
               "type":"Attribute_Field"
            },
            "people":"20",
            "class":"A",
            "archive":null,
            "type":"prog_asuh"
         }
      ]
   }
}

The attributes moves down because of the multi level object. I try another setting in tJSONDOcOutput but still the outcome is not like I want. How can I get this format? Can someone help me?

 

Labels (2)
2 Replies
root
Creator II
Creator II

Why would the order matter? This is the beauty of json objects. The receiving end needs to code it correctly regardless of the order of the elements. As long as the elements are in the correct hierarchy (as shown in your expected and original op, it should not matter.

However, if you still insist on generating the exact sequential output, then, the only way I can think of is generate each and every json element / array separately (multiple tjsondocopen/ tjsondocoutput) and then consolidate each of them sequentially in a master/ parent tjsondocopen/ tjsondocoutput in the correct output order.

root
Creator II
Creator II

Why would the order matter? This is the beauty of json objects. The receiving end needs to code it correctly regardless of the order of the elements. As long as the elements are in the correct hierarchy (as shown in your expected and original op, it should not matter.

However, if you still insist on generating the exact sequential output, then, the only way I can think of is generate each and every json element / array separately (multiple tjsondocopen/ tjsondocoutput) and then consolidate each of them sequentially in a master/ parent tjsondocopen/ tjsondocoutput in the correct output order.