How to output JSON records in multiple rows

One Star

How to output JSON records in multiple rows

Hi Experts,

I have generated a JSON output file using Talend. However, my problem is that all my records are outputted in 1 row in the JSON file. Below is the sample output:

My desired output is to have all JSON record separated by newline in the output file:

Thanks in advance for the feedback and help.
Six Stars

Re: How to output JSON records in multiple rows

replace "}," with "},\n"
One Star

Re: How to output JSON records in multiple rows

replace "}," with "},\n"

Thanks for the feedback.
But how do I process JSON file as plain text? When I try to process it, it is always filtered by column. For example, when I try to process the string, records are usually separated by field (field1, field2, field3) and not the whole string ({"field1":"value1_1","field2":"value2_1","field3":"value3_1"},{"field1":"value1_2","field2":"value2_2","field3":"value3_2"},{"field1":"value1_3","field2":"value2_3","field3":"value3_3"})
Six Stars

Re: How to output JSON records in multiple rows

After you wrote the json file, open it raw (tfileinputraw), read as string, searchn´replace in a tjavarowcomponent, write raw.
Take care about the Encoding
Seventeen Stars

Re: How to output JSON records in multiple rows

Oh dear... string manipulation to transform JSON? Seriously?
Why do you need to pretty print the output this way. For a technical usage of the file this does not makes sense. For the human read you can use tools which formats the file in a human readable way.
I would never ever manipulating the json content which such error prone methods.
Community Manager

Re: How to output JSON records in multiple rows

We really need some sort of +1 or Like mechanism in here jlolling :-)
I have to say I agree with Jan, but maybe you can explain why you need the JSON in that format ctufindgood? It does seem like a weird requirement, but I have also had many weird requirements from clients :-)
Six Stars

Re: How to output JSON records in multiple rows

@jolli: hopy you didn´t called me a dear  ...
One Star

Re: How to output JSON records in multiple rows

Hi jlolling and rhall2.0,
Yes, it is for a technical usage. It needs to accept data in the format of JSON, but the separator (",") actually needs to be replaced by newline character (\n).
Many Thanks.

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog