Six Stars

tWriteJSONField: why "Set As Loop Element"?

Looking at this scenario:

https://help.talend.com/reader/wDRBNUuxk629sNcI0dNYaA/oNb3uOB_7iXYY0w_dH3W2A

I read, at a certain point:

9. Right-click firstname and select Set As Loop Element from the context menu.

 

Well, the result is a "plain" json, without any loop element:

{"field1":"111","field2":"222","field3":"333"}

{"field1":"444","field2":"555","field3":"666"}

Why on earth field1 should be a "Loop Element"?

 

Thanks for your clarification,

Lorenzo

 

 

 

 

4 REPLIES
Community Manager

Re: tWriteJSONField: why "Set As Loop Element"?

Hello
To write a XML or Json field, you have to set a loop element. If you want to generate only one string, you need to define the group element also, the output string looks like:
{"rootTag":{"users":[{"id":"1","name":"shong"},{"id":"2","name":"elise"},{"id":"3","name":"ross"}]}}

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: tWriteJSONField: why "Set As Loop Element"?

Hi @shong

 

have you followed link I provided?

As you can see in the page linked, "firstname" is set as loop-element, and when you scroll down the page and take a look to the json result, firstname is definitely not a loop element (it is a string element, instead).

So, it is still not clear the purpose of defining firstname as loop-element when it is not.

Seven Stars

Re: tWriteJSONField: why "Set As Loop Element"?

Hi, is there any documentation on how to set an element as "group"? I am seeing that option grayed out all the time. 

Six Stars

Re: tWriteJSONField: why "Set As Loop Element"?

hi,

the loop element must be the finest level
If your json has a flat structure you do not have the group function.
to activate this last one it is necessary to create a node in which you can make a loop.
You can thus have the function group element