Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

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\": \"" +row7.name + "\"}";
      }
currentRow = currentRow+1;
}

How can I read rows and concatenate their data into a single string?
Labels (5)
1 Reply
Anonymous
Not applicable

Hello
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
Shong