I got this working  with a custom MessageBodyWriter. Not sure if there is a 
simpler way...anyways :-)

From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Tue, 5 Aug 2008 02:11:54 
+0000Subject: RE: JSON Set with JAXRS


I looked at the restlet example of Employees and changed my code to return a 
ItemList<Item> and got back a better JSON response like:{"class":"class 
Item","items":["[EMAIL PROTECTED]","[EMAIL PROTECTED]"]}What should I do to get 
the same back with {[id:10, name=car, id:21, name=tank]}, i.e., json 
representation of Item. I would not like to override the toString() method of 
Item to be in JSON format. Would I need to create custom message body writer 
for the Item class? Thanks in advance. 

From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Tue, 5 Aug 2008 00:38:29 
+0000Subject: JSON Set with JAXRS

Greetings, I am exploring Restlet's JAXRS support and trying the following in a 
Resource class: @[EMAIL PROTECTED]("application/json")public Set<Items> 
getItems() {    ....    return items;} When the call is made, the Resource is 
invoked, however the returned response is not a JSON formatted set but 
something like:{"empty":false,"class":"class java.util.HashSet"} Do I need to 
write some custom code to handle the mime type? I though JAXB, JSON etc were 
pretty much standard and I would have got back a JSON string like [[....] 
[....]]? Please let me know if I am missing something here. Thanks in advance 
for any tips... 

Your PC, mobile phone, and online services work together like never before. See 
how Windows® fits your life 

Your PC, mobile phone, and online services work together like never before. See 
how Windows® fits your life 
_________________________________________________________________
Got Game? Win Prizes in the Windows Live Hotmail Mobile Summer Games Trivia 
Contest
http://www.gowindowslive.com/summergames?ocid=TXT_TAGHM

Reply via email to