On Thu, Mar 15, 2018 at 11:44 PM, Vidyaranya Sai Nuthalapati <vidyaranya...@gmail.com> wrote: > I have a java object which has fields like content and customerName. I > serialize this object which will be something like: > > {"customerName" : "Dummy customer", "content" : [{"author" : "Arthur Canon > Doyle", "title" : "The adventures of Sherlock Holmes"}]} > > > When I try to deserialize it using objectmapper.readvalue it works fine and > I get back a proper POJO. > > > However, when I have a character in the title which contains the character é > it fails. For instance when I apply objectmapper.readvalue on > this{"customerName" : "Dummy customer", "content" : [{"author" : "Satoshi > Tajiri", "title" : "Pokémon"}]} > > > it fails with the error -> > com.fasterxml.jackson.databind.JsonMappingException: Unexpected > end-of-input: was expecting closing quote for a string value > > How do I get around this?
This is not enough to reproduce your problem: there is nothing special about characters like `é` and things should just work. But one common problem is that your content uses wrong encoding, and since this character happens to require 2 bytes in UTF-8, not one, you may have an anti-pattern somewhere in code: for example, a common mistake is to use something like: String name = new String(byteArray); which is typically a programming error since it does not indicate encoding to use. Proper usage would be String name = new String(byteArray, StandardCharsets.UTF_8); // or String name = new String(byteArray, "UTF-8") same applies to many JDK classes that do not require encoding (String.getBytes(), new InputStreamReadeR()). JSON assumes UTF-8 as the default encoding unless otherwise specified, and if your platform default encoding is something different (or, default of server that served/receives content is different, with code that relies on defaults) it is easy to get into mismatch. Otherwise you'd need to show code that reproduces the problem. Also note that printing out Strings on console is very prone to mismatched encodings: just because something looks correct (... or, wrong) does not guarantee that actual bytes in stream are correct. -+ Tatu +- -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscr...@googlegroups.com. To post to this group, send email to jackson-user@googlegroups.com. For more options, visit https://groups.google.com/d/optout.