How to create more complex JSON files with tFileOutputJSON

One Star

How to create more complex JSON files with tFileOutputJSON

I have used tFileOutputJSON as it is described in the documentation. This works without any problems.
However, this way I can only create very basic JSON documents, they have got this structure, for example:
{
"person":
}

Real world examples are more complex. How do I create same. Do I have to use List / Document or other Types in the Schema?
Is there any explanation, or any example / demo anywhere? Or do I have to try out by myself?

Thanks for help,
Kai
One Star

Re: How to create more complex JSON files with tFileOutputJSON

I have the same question.
How to write into a file multi level JSON structure?
Community Manager

Re: How to create more complex JSON files with tFileOutputJSON

Hi
Use a tWriteJsonFields to write a complex json string and output the string result to a file with tFileOutputDelimited. About the supported json types, you can refer to the following links:
https://www.talendforge.org/forum/viewtopic.php?pid=157898#p157898
https://jira.talendforge.org/browse/TBD-1067
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to create more complex JSON files with tFileOutputJSON

Hi
Use a tWriteJsonFields to write a complex json string and output the string result to a file with tFileOutputDelimited.

Thanks. 
It works but anyway I need some custom coding to make a usable JSON file.
One Star

Re: How to create more complex JSON files with tFileOutputJSON

Actually it works quite strangely.
I need to create a JSON file like that the one I attached: json_sample.txt.txt
One instance of  tWriteJsonField isn't enough to write the JSON because there is no way to create arrays. Possible solution may be to use one tWriteJsonField for each array I need in my final JSON and then construct an array using string manipulations (adding []) and then put it all together. 
The same in both Talend Open Studio and "full" version of Talend Studio.
Four Stars

Re: How to create more complex JSON files with tFileOutputJSON

 @martinsbi Hey, Can you explain what you did to create a multilevel nested array json structure.