Hi Sanjay,

Let's wait for Stephan to come back from his vacations and have a closer
look at your issue. If you want to make sure it isn't forgotten, you should
create a report in our issue tracker.

Best regards,
Jerome


-----Message d'origine-----
De : Sanjay Acharya [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 5 août 2008 17:58
À : [email protected]
Objet : RE: JSON Set with JAXRS


Jerome,

Thanks for the response. I am actually providing getters/setters for the
class. I also tried to get the JSON representation of the EmployeeList from
the Restlet example and that too does not marshall the details (unless I am
doing something wrong).  

Thanks,
Sanjay


________________________________
> From: [EMAIL PROTECTED]
> To: [email protected]
> Date: Tue, 5 Aug 2008 10:32:51 +0200
> Subject: RE: JSON Set with JAXRS
> 
> Hi Sanjay,
> 
> The JAX-RS spec doesn't mandate any particular JSON serialization. From
what I see the JSON provider shipped with Restlet/JAX-RS extension supports
automatic serialization of Map instances and of Java beans.
> 
> From the JSONObject(Object bean) Javadocs:
> 
> 
> * Construct a JSONObject from an Object using bean getters.
> 
> * It reflects on all of the public methods of the object.
> 
> * For each of the methods with no parameters and a name starting
> 
> * with "get" or "is" followed by an uppercase letter,
> 
> * the method is invoked, and a key and the value returned from the getter
method
> 
> * are put into the new JSONObject.
> 
> *
> 
> * The key is formed by removing the "get" or "is" prefix. If the second
remaining
> 
> * character is not upper case, then the first
> 
> * character is converted to lower case.
> 
> *
> 
> * For example, if an object has a method named "getName", and
> 
> * if the result of calling object.getName() is "Larry Fine",
> 
> * then the JSONObject will contain "name": "Larry Fine".
> 
> 
> Are you providing getters for your Item class?
> 
> Best regards,
> Jerome
> 
> 
> ________________________________
> De : Sanjay Acharya [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 5 août 2008 06:11
> À : [email protected]
> Objet : RE: JSON Set with JAXRS
> 
> I got this working  with a custom MessageBodyWriter. Not sure if there is
a simpler way...anyways :-)
> 
> 
> 
> ________________________________
> From: [EMAIL PROTECTED]
> To: [email protected]
> Date: Tue, 5 Aug 2008 02:11:54 +0000
> Subject: RE: JSON Set with JAXRS
> 
> I looked at the restlet example of Employees and changed my code to return
a ItemList 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]
> To: [email protected]
> Date: Tue, 5 Aug 2008 00:38:29 +0000
> Subject: JSON Set with JAXRS
> 
> Greetings,
> 
> I am exploring Restlet's JAXRS support and trying the following in a
Resource class:
> 
> @GET
> @ProduceMime("application/json")
> public Set 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 Find out how.

_________________________________________________________________
Get more from your digital life.  Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008=

Reply via email to