Need JAX-RS + JSON Good example
I try to retrieve a list of Object (ArrayList for instance) to a JSON representation For instance a sample User class: public class User { private String lastname; private String firstname; public User(){}; public User(String lname,String fname){ this.firstname = fname; this.lastname = lname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } } I want to retrieve a list of User like this @GET @Path(users) @Produces(MediaType.APPLICATION_JSON) public ArrayListlt;Usergt; getUsers() { ArrayListlt;Usergt; users = new ArrayListlt;Usergt;(); users.add(new User(userlastname1, userfirstname1)); users.add(new User(userlastname3, userfirstname2)); return users; } and I want to get this JSON representation [ { lastname: userlastname1, firstname: userfirstname1 }, { lastname: userlastname2, firstname: userfirstname2 } ] What is the best way to achieve this? The Restlet documentation mentioned the serialization proccess is automated, yes it#8217;s the case for only one Object like #8220;User#8221; new User(userlastname1, userfirstname1) return me the good JSON representation { lastname: userlastname1, firstname: userfirstname1 } If some one can give me some explanation about that. much appreciated Best regards -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Need-JAX-RS-JSON-Good-example-tp7290704p7290704.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2923428
RE: Restlet XStream/Jackson different JSON wrapper
What is the package name for the Element class? -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Restlet-XStream-Jackson-different-JSON-wrapper-tp7197038p7290802.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2923440
RE: V2. RC.3 : java.lang.NoSuchMethodError when POSTing xml
I've the same issue my war lib directory look like this appengine-api-1.0-sdk-1.6.2.jar appengine-api-labs-1.6.2.jar appengine-jsr107cache-1.6.2.jar c2dm-server.jar c2dm-server-src.jar datanucleus-appengine-1.0.10.final.jar datanucleus-core-1.1.5.jar datanucleus-jpa-1.1.5.jar geronimo-jpa_3.0_spec-1.1.1.jar geronimo-jta_1.1_spec-1.1.1.jar google_sql.jar gwt-servlet.jar javax.servlet.jar javax.xml.bind.jar javax.xml.stream.jar jdo2-api-2.3-eb.jar json-1.5.jar jsr107cache-1.1.jar org.codehaus.jackson.core.jar org.codehaus.jackson.mapper.jar org.json.jar org.restlet.ext.jackson.jar org.restlet.ext.json.jar org.restlet.ext.servlet.jar org.restlet.jar validation-api-1.0.0.GA.jar validation-api-1.0.0.GA-sources.jar An the exception Exception in thread main java.lang.NoClassDefFoundError: com/google/gwt/user/client/rpc/IsSerializable at org.restlet.ext.gwt.GwtConverter.getVariants(GwtConverter.java:75) at org.restlet.engine.converter.ConverterUtils.getVariants(ConverterUtils.java:93) at org.restlet.service.ConverterService.getVariants(ConverterService.java:116) at org.restlet.engine.resource.AnnotationInfo.getResponseVariants(AnnotationInfo.java:438) at org.restlet.engine.resource.ClientInvocationHandler.invoke(ClientInvocationHandler.java:217) at $Proxy5.getUsers(Unknown Source) at com.youfood.client.Client.main(Client.java:23) or Exception in thread main java.lang.NoClassDefFoundError: com/sun/syndication/feed/synd/SyndFeed at org.restlet.ext.rome.RomeConverter.getVariants(RomeConverter.java:76) at org.restlet.engine.converter.ConverterUtils.getVariants(ConverterUtils.java:93) at org.restlet.service.ConverterService.getVariants(ConverterService.java:116) at org.restlet.engine.resource.AnnotationInfo.getResponseVariants(AnnotationInfo.java:438) at org.restlet.engine.resource.ClientInvocationHandler.invoke(ClientInvocationHandler.java:217) at $Proxy7.retrieve(Unknown Source) at com.restletexample.Test.main(Test.java:18) Thierry Boileau wrote Hello, could you describe what are your needs? That is to says, the kind of Restlet extensions you need. Then, in each distribution, you can have a look at the /lib/readme.txt file. it lists extensions and their dependencies. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2702700 -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/V2-RC-3-java-lang-NoSuchMethodError-when-POSTing-xml-tp5114202p7292103.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2923513