Creating JSON file with a complex structure (several levels)

One Star

Creating JSON file with a complex structure (several levels)

Hello,
I try to create a json file from a data stream.
I created my json file ture in methadata then I build my job as follows:
it did not work, I have the impression that talend only generates a json file to a single level.
is what I can generate my file with this structure?
Can you help me?
thank you in advance.
Seventeen Stars

Re: Creating JSON file with a complex structure (several levels)

hi amallek,
I've tried to use tWriteJson Field for some same expectations ... without success (version 5.4.2) Smiley Happy
As you've said, it's only work for basic structures.
so my workaround is to use external java libs (as com.amazonaws.util.json : I was working with json + dynamoDB).
I'm not sure (and I don't think so) that this component has been improved since that version.
regards
laurent
One Star

Re: Creating JSON file with a complex structure (several levels)

Kzone thank you for the quick response.
I also did a search to see if talend can basically manage the json on many levels.
I found your answer that same subject https://www.talendforge.org/forum/viewtopic.php?id=44162 .
I just wanted to be certain that this is not possible with the component talend before starting the dev with a java routine.
Seventeen Stars

Re: Creating JSON file with a complex structure (several levels)

The only solutions I use in this case are:
1. try the Data Mapper - book a learning lesson before it is very complex!
2. Using the Java API Jackson and build the document with the clear and easy to use Java API in a tJavaRow or tJavaFlex.
I am working on a component writing complex JSON documents from various subjobs. Mostly I do not have all information in one flow, so I need a way to build the whole document in steps. The mentioned Java API is at the moment the best solution. 
One Star md
One Star

Re: Creating JSON file with a complex structure (several levels)

Can someone please tell how to define this Xpath or JSON schema in TALEND ...I am trying to read one sample file with tFileInputJSON ... How to understand the JSON format and write scheme in Talend


{
"id;firstname;lastname;address;date;revenue;states": "1;Andrew;Cleveland;South Roosevelt Drive;20/01/2005;55239;XX"
},
{
"id;firstname;lastname;address;date;revenue;states": "2;Franklin;Jefferson;Carpinteria Avenue;19/05/2006;78148;NC"
},
{
"id;firstname;lastname;address;date;revenue;states": "3;Calvin;Cleveland;Corona Del Mar;28/09/2000;77912;CT"
},
{
"id;firstname;lastname;address;date;revenue;states": "4;Grover;Ford;Cleveland Ave.;27/11/2001;76036;XX"
},
Seventeen Stars

Re: Creating JSON file with a complex structure (several levels)

hi milandhore,
have a look at this post about json format & useful 'chemin de fer' - don't know english expression Smiley Happy
http://www.json.org/
easiest way to parse some simple json format is to use metadata talend helper : in metadata , right clic on File Json and follow instruction to map your data.
hope it helps
regards
laurent