tWriteJSONField: why "Set As Loop Element"?

Seven 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

 

 

 

 

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
Seven 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.

Eight 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

 

 

One Star

Re: tWriteJSONField:


 

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog