struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: REST plugin, JSON
Date Sat, 15 Nov 2008 02:00:48 GMT

>> Hi All,
>>
>> I am using the latest 2.1.3 snapshot (as opposed to 2.1.2) because I
>> have hierarchical resources. I've sent two emails to the users list
>> but they have gone unanswered, and since the questions are about the
>> 2.1.3-SNAPSHOT version it may be better to post them here anyway so
>> here they are:
>>
>> 1.  I want to make sure that the content encoding for the JSON output
>> from the server is always in UTF8. How can I do this?
>> 2. I noticed that when the plugin serializes the response to JSON a
>> null string is serialized as an empty string and a null array is
>> serialized as an empty array. Would it be more correct to serialize
>> them as null? I would like to distinguish between a null string and an
>> empty string.
>> 3. The plugin sets the content type to text/javascript. I am not sure
>> if application/json (http://www.ietf.org/rfc/rfc4627.txt?number=4627)
>> is more appropriate?
>>
>>     

Hi Alex, just a quick answer sorry.

Use the plugin config to the default handler for json.
In your handler, setup json lib with a custom JsonConfig instead of the 
default.

Question 2 is a jsonconfig option described here: 
http://json-lib.sourceforge.net/advanced.html
Question 3 is just a property of the custom handler (getContentType)

I haven't seen where to control the encoding but I'm sure it's in there 
somewhere.

I've done this myself to customize the serialization of java.sql.Date.

regards,
 Jeromy Evans


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message