Parsing JSON in Talend

0 votes
How can I parse JSON docs into Java codes in a Talend Job? As each of my source files contains a several hundred JSON docs and a single JSON doc takes up an entire line of the file I am unable to use tFileInputJSON. I've been looking for a component which can work out with this but have failed to do so. As per my research, it seems tFileInputJSON is relatively new. Can anyone suggest any strategy to deal with this?
Apr 3, 2018 in Talend by misc.edu04
• 1,450 points
3,639 views

1 answer to this question.

0 votes

While working with JSON files, one thing you must remember is that Talend doesn't support any JSON component like tExtractXMLField or so. 

What should you do?

So, in order to solve this problem you need to follow the below steps:
STEP 1: First, you need to read the data from the source file line by line.
STEP 2: Next, you need to save the current line in a new delimited file (test.txt).
STEP 3: To extract test.txt, you can make use of tFileInputJSON and then perform the job logic.
STEP 4: Now using tFileDelete, you can delete the test.txt file and go to the next iteration of every new line.

Or the other way you can try out is, by using Custom Routines.

Routines in Talend work similar to Java functions using which you can write your own custom code. These can be invoked from anywhere inside a Job (using tMap, tJava etc.). These routines can then write in a file, print on a screen or return some list objects which you can utilize with another tJava, tJavaFlex, tJavaRow or any other components in a job.

At first, creating routines may look little complex and time consuming, but I can assure you that it will definitely help you in the long run.

Hope this will help!

Join the Talend course today to know more about and become expert.

Thanks.

answered Apr 3, 2018 by code.reaper12
• 3,500 points

Related Questions In Talend

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Converting Columns into Rows in Talend

Hi, You can try using tNormalize component along ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points

edited Apr 11, 2018 by code.reaper12 5,996 views
0 votes
1 answer

Looping through all the schemas in Talend

It is really simple to make tOracleInput ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points
1,534 views
0 votes
1 answer
0 votes
1 answer

Adding third party libraries into the Talend project

You can add the 3rd party libraries ...READ MORE

answered Apr 9, 2018 in Talend by code.reaper12
• 3,500 points
3,458 views
0 votes
1 answer

Parsing Date Error in Talend

This job doesn’t needs tConvertType. You can ...READ MORE

answered Apr 19, 2018 in Talend by code.reaper12
• 3,500 points
3,852 views
0 votes
1 answer

Performing a JSON Deserialization in Talend

tExtractJSONFields component helps in extracting the desired ...READ MORE

answered Apr 19, 2018 in Talend by code.reaper12
• 3,500 points
1,909 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP