java - Jackson error : unacceptable character '' (0x0) special characters are not allowed -


i'm trying parse yaml data using jackson mysql error saying there special character. error :

com.fasterxml.jackson.databind.jsonmappingexception: special characters not allowed  [source: java.io.stringreader@5528a42c; line: 13, column: 68] (through reference chain: com.app.resultcontentmodel["opinion"]) ... caused by: com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.yamlexception: special characters not allowed  @ [source: java.io.stringreader@5528a42c; line: 13, column: 68] ... caused by: unacceptable character '' (0x0) special characters not allowed in "'reader'", position 1027 

my dependencies file :

<dependency>         <groupid>mysql</groupid>         <artifactid>mysql-connector-java</artifactid>         <version>5.1.6</version> </dependency> <dependency>         <groupid>com.fasterxml.jackson.dataformat</groupid>         <artifactid>jackson-dataformat-yaml</artifactid>         <version>2.8.1</version> </dependency> 

i'm trying replace using regex :

pattern nonascii = pattern.compile("[^\\x00-\\x7f]");//("[^\\x00-\\x7f]"); resultcontent = normalizer.normalize(nonascii.matcher(resultcontent).replaceall(""); resultcontentmodel rc = mapper.readvalue(resultcontent, resultcontentmodel.class); 

but still didn't work. should do?

it seems want match non-ascii + characters hex codes 00 till 20 (space).

use

pattern nonascii = pattern.compile("[^\\x00-\\x7f]+|[\\x00-\\x20]+"); 

the \x00-\x20 match control characters need remove , [^\x00-\x7f] match non-ascii chars.

the + quantifier match 1 or more occurrences, remove/replace character chunks matched in 1 go.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -