开发者

RESTlet tutorial application does not return Java Objects (JSON only)

开发者 https://www.devze.com 2023-01-25 07:12 出处:网络
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

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(); 
0

精彩评论

暂无评论...
验证码 换一张
取 消