Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Escape Special characters - tWriteJSONField

Getting below mentioned error. source attribute had a value with special character '&'. Due to that i am getting this error in tWriteJSONField.

my requirement is to convert source data to Json file. 

Could anyone advise how to escape those special characters without replacing or removing those characters. I mean i want to send the information to target which i am receiving from source.

 

 

FATAL TERMS_DATA_EXTRACT_GEN:8131 - tWriteJSONField_1_In nu.xom.ParsingException: Character reference "&# at line 1, column 92

2019-03-15 09:31:04 FATAL TERMS_DATA_EXTRACT_GEN:2896 - tWriteJSONField_1_In nu.xom.ParsingException: Character reference "&# at line 1, column 92

[Fatal Error] :1:92: Character reference "&#

Exception in component tWriteJSONField_1_In

net.sf.json.JSONException: nu.xom.ParsingException: Character reference "&# at line 1, column 92

at net.sf.json.xml.XMLSerializer.read(XMLSerializer.java:331)

Labels (5)
7 Replies
Anonymous
Not applicable
Author

Hi,

 

Could you please check the details in this link?

 

https://stackoverflow.com/questions/19176024/how-to-escape-special-characters-in-building-a-json-str...

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

Hi Nikhil,

It didn't help... i tried several ways and i am still hitting the same issue.

 

1) replaced '&' with  '//&'

2) TalendString.replaceSpecialCharForXML(input)

Anonymous
Not applicable
Author

Hi,

 

    Could you please share 3 or 4 ample input records and expected output record. We will try to fill in the missing part then.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

pheld
Contributor

hi @RAVI KOPPARAPU​ ,

I've come across this problem and found out, that there are even more special ("invisible") characters that are causing problems in the component tWriteJSONField.

I built my own program to delete these unnecessary values. In case you want to keep them try to escape them with backslash:

 

In the routine I replaced as follows:

 

  public static String removeControlChar(String input) {

    input = input.replaceAll("\u0000", ""); //remove control character NUL (hex value 0x00)

    input = input.replaceAll("\u0002", ""); //remove control character STX (hex value 0x02)

    input = input.replaceAll("\u000b", ""); //remove control character VT (hex value 0x0B)

    input = input.replaceAll("\u000e", ""); //remove control character SO (hex value 0x0E)

    input = input.replaceAll("\u000f", ""); //remove control character SI (hex value 0x0F)

    input = input.replaceAll("\u0010", ""); //remove control character DLE (hex value 0x10)

    input = input.replaceAll("\u0003", ""); //remove control character ETX (hex value 0x03)

return input;

}

cara_ay
Contributor II

Hi @RAVI KOPPARAPU​ Just wondering if you had managed to find a solution to this? Would you by any chance remember what the solution was as I am currently experiencing the same issue.

gjeremy1617088143

HI,@Cara Au Yeung​  could you send an example of the json file wich causing issues ?

Send me love and kudos

 

cara_ay
Contributor II

Hi @guenneguez jeremy​ Thanks for the offer but I've actually managed to find the cause of the issue. I was querying the MySQL database to genereate the json file. It was the backspace (\b) characters in the MySQL database that were triggering the error in Talend.