My understanding is that JSON is always UTF-8 by definition.
Mark
On Wednesday, 1 April 2015, Craig McClanahan <craigmcc_at_gmail.com> wrote:
> What I do for this is use a produces annotation like this on the server:
>
> @Produces("application/json;charset=UTF-8")
>
> which causes the content type header to be set like this:
>
> Content-Type: application/json;charset=UTF-8
>
> Clients should just say @Accepts("application/json") to tell the server
> they can understand UTF-8 (and pretty much anything else the server might
> send). Asking for something specific that is different from what the
> server sends is likely to cause you errors.
>
> Likewise, clients should set the content type header appropriately when
> they send.
>
> Craig
>
> On Tue, Mar 31, 2015 at 4:09 PM, Simon Roberts <
> simon_at_dancingcloudphotography.com
> <javascript:_e(%7B%7D,'cvml','simon_at_dancingcloudphotography.com');>>
> wrote:
>
>> Hi all, I have a question; partly this is a philosophical thing, partly
>> it might have code-level consequences.
>>
>> If I'm sending structured data (e.g. a JSON object) from the server to
>> the client, and the structure contains ... er, I'm not even sure of the
>> right terminology, I want to call them "high order Unicode characters", or
>> "text that's not plain ASCII" .. I think there are some things I need to
>> pay attention to, but I'm not sure what they are.
>>
>> Can someone give me an outline of the concerns and mechanisms, in
>> particular, what does JAX-RS handle automatically, and what do I have to do?
>>
>> For example, suppose I'm trying to send some Chinese text in JSON. Does
>> the JSON conversion have to know the target charset? If so, does JAX-RS
>> tell it? Does the JAX-RS infrastructure check the accept-charset header and
>> will it ensure the right response? So, for example, if the client asks for
>> some specific ISO-8859 character set, but my server machine generally runs
>> in UTF-8, will (good) magic occur on output? How about on input? And if
>> magic isn't magical, what do I have to do to make this work.
>>
>> BTW, I realize this is a potentially large topic, so a reference would be
>> fine. I tried to look in the Jersey docs, and didn't find anything (might
>> have missed it, of couse!)
>>
>> Many thanks,
>> Simon
>>
>> --
>> Simon Roberts
>> Certified Professional Photographer
>> http://dancingcloudphotography.com
>> (303) 249 3613
>>
>
>