Hi Laurent, In order to have this automatic conversion to XML or JSON happen, you need to add the "org.restlet.ext.xstream.jar" and *all* its dependencies in your classpath, including Jettison. The Restlet engine should detect it and leverage it to convert your Profile objects in both directions, from JSON or to JSON.
Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : Laurent Rustuel [mailto:[email protected]] Envoyé : vendredi 4 septembre 2009 10:04 À : [email protected] Objet : automated conversion from java object to json Hello, I'm looking for info about automatic conversion from java object to json in restlet. I have read this thread [http://markmail.org/thread/g7u4rmje64rhk6q5] and the resulting page in the wiki [http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/285-restlet.html] but I have still some problems to make it works. I have a resource to retrieve customer profile : public class ProfileResource extends ServerResource { @Get public Representation getJson() throws ResourceException { // get Profile object matching the request [...] Profile profile = new Profile(); JSONObject jsonProfile = new JSONObject(profile); getResponse().setStatus(Status.SUCCESS_OK); return new JsonRepresentation(jsonProfile); } } So from what I have read, I can declare my annotated method to return directly a Profile object, and not a Representation. Now if I try to get the profile, no converter can be found ( ATTENTION: Unable to find a converter for this object : [...] ) either with curl with header Accept set to json or xml, or using a browser, so I don't get any entity in response. My questions here are : How can I specify make my object to be automatically converted to xml or json ? change something in my object itself, or in my resource ? Or maybe I need my own /ConverterHelper/ ? If so, is there any documentation or guide line for this task (I have found nothing yet) ? Thanks for any help, Laurent. -- Laurent Rustuel, Alten contractor for Alcatel-Lucent, Brest ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=23909 50 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2402812

