Concatenate Rows into a JSON String

One Star

Concatenate Rows into a JSON String

I need to write a job that reads rows from a table and posts those records to a REST Web service with a JSON Object.
I'm newer to Talend so I need some advice.  how/or which is the best way to concatenate rows into a JSON string object?
I tried using a THashInput component to hold the rows and then a tJava components to loop through the records but this just gives me one record at a time.  Is there a way I could write a loop that would read all the records from the tHashInput object?
int currentRow=0;
while (currentRow<= tHashInput.lenght90)
//create a JsonString with 10 row records each
     for(i=0; i<=10; i++)
        JsonString = JsonString  + "{\"u_Name\": \"" + "\"}";
currentRow = currentRow+1;

How can I read rows and concatenate their data into a single string?
Community Manager

Re: Concatenate Rows into a JSON String

Take a look tJavaFlex component, you can initialize a string in the begin part, and concatenate all the input records in the main part, and finally, store the string to global variable for used later on other component, you can find some explanation and an example about tJavaFlex in this KB article, let me know if you have any doubts.
Best regards
Talend | Data Agility for Modern Business