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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to create nested json array through talend job?

Hello,

 

My requirement is to create json message as an output which will have nested array list. I tried to achieve it using twritejsonfield component but this supports only one loop element. Do we have some provision in talend which will allow us to set multiple elements but nested ones as loop elements through which I may achieve desired output:

 

Output Message Generated:

{"navDate":"2018-06-19T00:00:00",
"clients":
[
{"name":"SLB","fundGroups":{"name":"IBOR-DALY","funds":{"name":"I0AO","rules":{"systemName":"Valuation","startdate":"2018-06-20T10:00:00"}}}},
{"name":"SLB","fundGroups":{"name":"IBOR-DALY","funds":{"name":"I247","rules":{"systemName":"Valuation","startdate":"2018-06-19T10:00:00"}}}},
{"name":"SLB","fundGroups":{"name":"IBOR-DALY","funds":{"name":"I520","rules":{"systemName":"Valuation","startdate":"2018-06-20T10:00:00"}}}}
]
}

 

Desired Output Message:

{"navDate":"2018-06-19T00:00:00",
"clients":
[ {"name":"SLB","fundGroups":[{"name":"IBOR-DALY","funds":[{"name":"I0AO","rules":[{"systemName":"Valuation","startdate":"2018-06-20T10:00:00"}]},{"name":"I247","rules":[{"systemName":"Valuation","startdate":"2018-06-19T10:00:00"}]},{"name":"I520","rules":[{"systemName":"Valuation","startdate":"2018-06-20T10:00:00"}]}]}]}
]
}

Labels (4)
2 Replies
Jesperrekuh
Specialist
Specialist

Not really sure how to achieve what you want ...
I use tXMLMap, create a column of Document type and aggregate and loop on the lowest level, like this structure:
-- out
---- navData
---- clients
--------- name <---- aggregate
--------- fundgroups
----------------- name
----------------- funds
-------------------- name <--- loop level
-------------------- rules
------------------------- systemName 
------------------------- startdate

Anonymous
Not applicable
Author

Hi,
I faced the same scenario couple of years back. Then, first I created the nested XML, then I converted the XML generated to the JSON using the java classes in tJavaRow component.

I hope that could give you a solution, Also what I could remember is I was not able to achieve it using the tWriteJsonFields.

Best Regards,
Abhishek