Five Stars

How can I write JSON object and other columns into same output

Hello, 

 

I need some help in resolving below issue. I am new to Talend just started using it from past one week.

 

My requirement is to read input data, convert it into JSON record(s) and load it into database table as JSON column. I am able to do this without any issues.

 

Now, I want to load key column as a separate column so that I can search easily based on key.

 

for example I have below 3 columns in my input

ID

NAME 

ADDR

 

I have to load ID into a separate column and convert (ID, NAME and ADDR) into JSON and load into a separate column.

 

My current job looks like below:

 

Input --> tMap1 --> tJavaRow (setting the global variable here with 'ID' using globalMap.put )

                                    --> tMap2 --> tJSONWriteField --> tMap4(getting the global variable back using globalMap.get)

                                                                     --> tLogRow_1.

 

Last record's 'ID' value is assigned to all output records. If replace tJSONWriteField with tMap, I am getting correct 'ID' value for each record.

 

Please let me know what did I do wrong or is there any better way of doing this.

 

I am using "Talend Open Studio for Data Integration Version: 6.4.1(64 bit)"

 

Thank you very much for your time and help.

                            

 

1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: How can I write JSON object and other columns into same output

I am able find a work around for this by changing my job like below

 

Input --> tJSONWriteField --> tJavaRow(extracted my required key fields from JSON using Java code and populated them as output fileds)--> tLogRow_1.

 

In this case, even tJSONWriteField releases all records at once still no issue. But I don't know the reason why this component holds all records and releases all of them at once.

 

Please let me know if anyone knows the reason or a solution to make tJSONWriteField release each record immediately without holding it.

 

Thank you,

2 REPLIES
Five Stars

Re: How can I write JSON object and other columns into same output

Its happening because tWriteJSONField is not releasing every row. Its releasing all rows at once, by that time global variable is getting reset multiple times, when I use tMap its not happening because, tMap is not holding the records and releasing it immediately.

 

How can I make tWriteJSONField to release each record without holding it.

 

Five Stars

Re: How can I write JSON object and other columns into same output

I am able find a work around for this by changing my job like below

 

Input --> tJSONWriteField --> tJavaRow(extracted my required key fields from JSON using Java code and populated them as output fileds)--> tLogRow_1.

 

In this case, even tJSONWriteField releases all records at once still no issue. But I don't know the reason why this component holds all records and releases all of them at once.

 

Please let me know if anyone knows the reason or a solution to make tJSONWriteField release each record immediately without holding it.

 

Thank you,