Search code examples
javarestjava-ee-7

What is the default character encoding for JAX-RS?


After some unsuccessfully searching I try good old SO in order to find someone to point me to the right spot of some specification.

I know that I can set the character encoding of some REST call by e.g.:

@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") 

But if I omit the charset-part, is there a default character encoding defined which a client can assume to be present? And is this specific to either REST in common, JAX-RS in particular or even a special implementation like RESTeasy?


sisiphus pointed me to the right place - I wasn't aware that I had to look specifically for JSON since I set this as content type. Nevertheless, one question remains - if no media type is definded, what would then be the default if any?


Solution

  • https://www.rfc-editor.org/rfc/rfc7159#section-8.1

    JSON defaults to UTF-8. UTF-16 and UTF-32 are also allowed.