JAX-RS Encoding

I use JAX-RS to create a web service (rest) that returns results in JSON format.

Everything is in order, except for the encoding.

For example, I get:

..., parameter:"Dep\u00f3sitos" ,... 

Instead:

  ..., parameter:"Depósitos" ,... 

I tried using:

 @Produces("application/json; charset=UTF-8") 

but the problem remains. If I return it to XML, simply:

 @Produces("application/xml") 

Everything is good.

What do I need to create the correct type?

+8
java json rest encoding jax-rs
source share
3 answers

I ended up using GSON instead of IBM JSON4J, which turned out to be much better when handling custom serialization of the Java class.

+1
source share

Take a look at Bryant Luca answer the question How to set the encoding using JAX-RS? "and see if this does the trick.

0
source share

All you need is:

 String back = "Depósitos"; return new String(back.getBytes(), "UTF8"); 
0
source share

All Articles