Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tWriteJSONFields with multiple repeating elements

Hi all, I write to asky you for some hint on how to create a JSON document using the tWriteJSONField component

The JSON document has the following structure:
{
  "doc_key": "d_10000001_02/2016",
  "doc_type": "monthly_detail",
  "account_no": "10000001",
  "month": "02/2016",
  "bill_details": [
    {
      "created_date": "01/02/2016",
      "amount": 46.9,
      "is_recurring": "Y",
      "start_date": "01/02/2016",
      "end_date": "01/03/2016"
    },
    {
      "created_date": "04/02/2016",
      "amount": 10,
      "is_recurring": "Y",
      "start_date": "04/02/2016",
      "end_date": "04/03/2016"
    }
  ],
  "payments": [
    {
      "payment_date": "02/02/2016",
      "payment_type": "Credit Card",
      "amount": -110.53
    },
    {
      "payment_date": "03/02/2016",
      "payment_type": "Credit Card",
      "amount": 50.50
    }
  ]
}

As you can see it has a "header" with no repeatable elements and two repeating "arrays".
All these fields are stored in a database and they are getted with different queries.
Currently I reached the goal to create the JSON document using custom Java classes that model the JSON, populating an object with the elements extracted by queries and then "marshalling" the object using Google's Gson classes.

Below a screenshot of the job I've created.
0683p000009MHFo.png 

It properly works but I would like to use the Talend's native components instead of Java custom code in order to obtain this JSON object. In addition, for future improvements, the tWriteJSONField should refer to JSON metadata that would permit "simple" updates (not manually updating the XML tree of the component).

I've tried to do it but the multiple repeating structure of the JSON seems to don't allow this kind of solution.
Have you any hint?

Thank you in advance

Labels (2)
1 Reply
Anonymous
Not applicable
Author

Hi,
Have you tried to use component TalendHelpCenter:tXMLMap to see if it works?
Best regards
Sabrina