users@jersey.java.net

[Jersey] Re: how to rename XmlRootElement in JSON

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 14 Jun 2011 10:59:41 -0700

On Tue, Jun 14, 2011 at 3:23 AM, Maxrunner <joao.rossa_at_gmail.com> wrote:
> Yeah, with this resource:
> @GET
> @Produces("application/json")
> @Path("/getOrganica")
> public Response getOrganica(){
> System.out.println("super porra utf-8!");
> Object entity=fillOrganica(123,"Organicão Mind","2010-12-23",true);
> //return fillOrganica(123,"Organição Mind","2010-12-23",true);
>   return Response.ok(entity).header("charset", "UTF-8").build();
> }
>
> I get this on chrome:
>
> {
> "Organica" : {
> "designacao" : "Organicão Mind",

It looks like Chrome somehow assumes that encoding of content is
latin-1; and as such incorrectly decodes byte stream (which is in
UTF-8) to display two characters, instead of a two-byte Unicode
character it should display.

Does anyone else know if this is a known Chrome issue? I think it is
also possible to define encoding with media type used with @Produces;
something like "application/json; charset=utf-8". Would that help in
your case?

-+ Tatu +-