Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
JGuttmann1675784205
Contributor
Contributor

Create a JSON Array for rows

Hello,

i have designed a job with a loop which is getting some database-data as rows. I want to transform these data into an jsonarray.

The JSON should look similar to this:

[{coding":"182321|155246|6843-6900,183670-1597:2296","catalogNumber":"602","validAt":"2022-09-30"},{coding":"182321|155246|6843-6900,183670-1597:2296","catalogNumber":"602","validAt":"2022-09-30"}]

I tried to achieve this by following the instructions here:

https://help.talend.com/r/en-US/8.0/processing/twritejsonfield-tmap-trowgenerator-trowgenerator-converting-rows-to-json-array-to

this is working fine as long as I have some input with more than one row. Since i can not guarantee that there will always be more then one row (remember I'm doing a loop with many iterations) I need an approach which also works for one row.

If i have only one row as input I get:

{"loop":{"coding":"182321|155246|6843-6900,183670-1597:2296","catalogNumber":"602","validAt":"2022-09-30"}}

what I'd like to achieve is an array with only one object:

[{coding":"182321|155246|6843-6900,183670-1597:2296","catalogNumber":"602","validAt":"2022-09-30"}]

Are the any recommendations how to achieve this?

Best regards

Janina

Labels (3)
1 Reply
Anonymous
Not applicable

Hi

Take a look at this topic, phancongphuoc has the same issue and he suggested a workaround.

 

Regards

Shong