One Star

tSAPInput: Write JSON with multiple rows in table output

Hi Smiley Happy
after my first problem was sloved, i stuck at the next step: Parsing the SAP output into JSON.
The outputs with the type output_structure are easy. Not so easy is the type output_table. This may contains more than one rows. Talend iterate now over all data rows and executing all components in the chain many-times.
My question is now: What is the best way to write this data rows into JSON?

Here is my job:


Example:
SAP returns the following table:
 ID         | Name           | Info
------------------------------------------------------
01         | Test           | My Info #1
02         | Test #2        | My Info #2


Expected JSON:

{"RESULT":}


Thank you very much! Smiley Happy
"Talend Open Studio for ESB"
Version: 5.5.1
Build id: r118616-20140617-1132
4 REPLIES
Moderator

Re: tSAPInput: Write JSON with multiple rows in table output

Hi,
Here is a component TalendHelpCenter:tWriteJSONField which transforms the incoming data into JSON fields.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: tSAPInput: Write JSON with multiple rows in table output

Hi,
Here is a component TalendHelpCenter:tWriteJSONField which transforms the incoming data into JSON fields.
Best regards
Sabrina

Hi Sabrina,
i already use this component and it works well. My problem is, that the tSapInput component returns a output_table (which contains many data rows). I need to create a JSON Array containing all data rows from the SAP output.
This JSON Array must be a part of a JSON String which is generated from the other SAP Outputs.

Lets say SAP returns the following data:
A table (output_table, contains 0..n rows):
 ID         | Name           | Info
------------------------------------------------------
01 | Test | My Info #1
02 | Test #2 | My Info #2


And a structure (output_structure, contains only one row):
CustomerName=Bond
CustomerPrename=James


Expected JSON:
{"CustomerName":"Bond","CustomerPrename":"James","tableOutput":}


With the tWriteJSONField it no problem for me to create a JSON from the structure. I have only trouble with the table.

Thanks!
One Star

Re: tSAPInput: Write JSON with multiple rows in table output

Here an example:


I don't want 5 JSON Strings (see what tLogRow gets). I want one JSON String with an Array inside. How can I do this with talend?

Thank you very much!

I have now the same problem as clorenz (http://www.talendforge.org/forum/viewtopic.php?pid=112669) one year ago.
One Star

Re: tSAPInput: Write JSON with multiple rows in table output

Hi,
I have an issue somewhat similar to the one mentioned here.
I am trying to create an array of json records out of a tsv file but this particular array element has values separated by commas.
I want the following structure:
,
12            "parentGroupId": "790"
13        }
14    ]
Here, I want the square brackets surrounding the mediaTypes element and the values "Online", "Print" come from a single column of a tsv file.


Is this possible?
Thank you.