Output Encoding

Showing 1-4 of 4 messages
Output Encoding Indu 9/24/12 1:33 AM
Hi all,

       I m developing RESTful web services in which the whole client is built upon the APIs provided and the client is completely stateless. Got into a big dilemma whether to provide the output encoding in the JSON response of the resource or not

Thanks for looking into this.

Thanks
Indu
Re: Output Encoding Raghuveer Rao 9/24/12 8:11 AM
You are building a service. This service can be potentially used by multiple clients. 
Rest allows clients to negotiate the format in which they want the output.
This is done by the request header / response header.

Raghu
Re: Output Encoding slam 9/24/12 8:20 AM
If encoding is in the JSON response, how can you read the JSON to know what encoding to use?

It's a catch 22. http://en.wikipedia.org/wiki/Catch-22_%28logic%29

Also, being restful means that the communication concerns are abstracted over a communication layer (ie: http in you case), and the api concerns is to provides information about the resource.

I think you should use the http headers to specify your encoding. exemple: Content-Type: application/json; charset=utf-8

That's in an ideal world. You don't give much information on your context, so maybe our friend the "real world" can make the final decision different.
JF


On Monday, September 24, 2012 4:33:05 AM UTC-4, Indu wrote:
Re: [api-craft] Re: Output Encoding Steve Klabnik 9/24/12 8:36 AM
As I said in the other thread, JSON is UTF-8, 16, or 32. Section 3:
http://www.ietf.org/rfc/rfc4627.txt

JSON text SHALL be encoded in Unicode.  The default encoding is
   UTF-8.

   Since the first two characters of a JSON text will always be ASCII
   characters [RFC0020], it is possible to determine whether an octet
   stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
   at the pattern of nulls in the first four octets.