RESTlet tutorial application does not return Java Objects (JSON only)
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-examp开发者_JAVA技巧le-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.
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();
精彩评论