Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-226

Unable to set character encoding of JSON output

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.1.RC2
    • 1.0.2.GA
    • jaxrs
    • None

    Description

      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

      { marshal(o, new OutputStreamWriter(outputStream)); }

      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

      Attachments

        Issue Links

          Activity

            People

              patriot1burke@gmail.com Bill Burke (Inactive)
              beepbeep_jira Balazs Pataki (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: