0

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

[{"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"}]

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

[{"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"}]

Thanks in advance for the help!

1
  • 1
    Being a curious person and all, I have to ask, why do want to achieve this, how will it help you?
    – erikvimz
    Commented Jun 1, 2016 at 9:13

2 Answers 2

1

There is no direct way to do it, but if it's necessary you can re-read the file as raw file using a tFileInputRaw component then replace all },{ by },\n{ in a tJavaRow component.

2
  • Hi, How do I re-read the file as raw file using tJavaRow component?
    – Daniel Lee
    Commented Jun 6, 2016 at 2:31
  • @DanielLee Updated answer !
    – 54l3d
    Commented Jun 6, 2016 at 10:11
0

Use the tFileOutputJSON component, which will help collect the rows as a list into JSON file. You may then use a tFileInput Component to read it and send it as Response.

1
  • It seems more like a comment. Provide some explanation to your answer. Commented Jan 23, 2017 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.