4

I've been looking the source code available from the Restlet official tutorial.

I am trying to hit the Restlet server using the Android app from he tutorial adn I only get the JSON response, not the Java Object. I tried using all libraries and extensions, nothing works. When I hit the tutorial url though ( http://restlet-example-serialization.appspot.com/contacts/123) I get the desired response. Any ideas? BTW, I am just using the server (GAE) in the example, not the GWT frontend.

Yi Jiang
  • 49,435
  • 16
  • 136
  • 136
oviroa
  • 1,079
  • 2
  • 12
  • 29

1 Answers1

-1

Use GSOn to convert json to java object. GSON you can get from google as its their code:

http://code.google.com/p/google-gson/

Other way:

Response res = client.handle(req); 
    ObjectRepresentation<Item> obj = new ObjectRepresentation<Item>(res.getEntity()); 
    Item item = obj.getObject(); 
Fred Grott
  • 3,505
  • 1
  • 23
  • 18
  • I do not want to do that. In theory, the beauty of Restlet is that you are dealing with Java objects only and you don't have to serialize/deserialize. Any other ideas? – oviroa Nov 15 '10 at 15:14
  • The other way is: Response res = client.handle(req); ObjectRepresentation obj = new ObjectRepresentation(res.getEntity()); Item item = obj.getObject(); – Fred Grott Nov 15 '10 at 18:50
  • 1
    So in the Android client, the tutorial has this piece of code: contact = resource.retrieve(); where contact is of type Contact and Resource is of type ContactServerResource. How does your code replace that? And why does this code work when I access the estlet-example-serialization app but not when I deploy the code under my app in GAE? – oviroa Nov 15 '10 at 20:46