Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Empty string value is output as empty array

Hi,


I am using tWriteJSONField to output JSON. Problem I am facing is whenever a string comes with null value, it is stored as [] ie "emtpy array" , although it should be "" i.e. "empty string", ARE there any fixes Talend has provided for this issue? I can do a simple find and replace, but wondering if there is any configuration or available fix for this. I am using Talend Studio 6.3.

Labels (5)
5 Replies
Anonymous
Not applicable
Author

Hello,

Here is a related jira issue:https://jira.talendforge.org/browse/TDI-31237.

Could you please check it to see if it is what you are looking for?

Best regards

Sabrina

heshkaru
Creator
Creator

Hi @Xiaodi Shi​ ,

Came across this issue.

 

When I log it "site_id" shows empty.

0695b00000PMqNkAAL.pngWhen I use twritejsonfield and out to a json file it changes to empty [].

 

0695b00000PMqOYAA1.png 

Any solution for this?

 

Thank you

gjeremy1617088143
Master
Master

HI @Heshan Karunaratneyou could try to play with advanced option of the component like pass empty string or null value explicitly else you could try to add a tJavaRow after the tWriteJsonfield then in the tjavaRow :

output_row.string = input_row.string.replaceAll("\\[\\]","\"\"");

 

it will replace [] by ""

 

here i assume your json schema field name is string

Send me love and kudos

heshkaru
Creator
Creator

Hi, For 50% this option is ok.

output_row.string = input_row.string.replaceAll("\\[\\]","\"\"");

But in my json object there are specific arrays and objects as well. For an empty array [] is fine.

Im specifically replacing them first and doing the rest to the others.

gjeremy1617088143
Master
Master

you could focus on specific field like input_row.string.replaceAll("\"site_id\":\\[\\]","\"site_id\":\"\"");