I'm unable to set the character encoding of the generated JSON output.
I tried
@Produces("application/json; charset=UTF-8")
but it doesn't seem to have effect (I tried "utf-8" as well). The output is always ISO 8859-1, which is the default encoding of my Java VM.
Looking into the code and debugging it some, I found out that the following method of JettisonMappedMarshaller gets invoked:
public void marshal(Object o, OutputStream outputStream)
throws JAXBException
This one creates an OutputStreamWriter from an OutputStream. However, it doesn't set the encoding to be used in the writer, so it will be the default one (8859-1 in my case). I tried this with
marshal(o, new OutputStreamWriter(outputStream, "UTF-8"));
and then it generated proper UTF-8 at the end.
I don't know if this is the approriate solution, or how the actual output encoding should be set, but this seems probelmatic for me. Or if i'm doing something wrong I would be happy to get information how to set proper Resteasy/JAXB/JSON output encoding
Regards,
—
balazs
- relates to
-
RESTEASY-465 Character encodings not respected by RestEasy
- Closed
-
RESTEASY-467 StringTextStar character encoding support
- Closed