gpt4 book ai didi

android - RESTlet 教程应用程序不返回 Java 对象(仅限 JSON)

转载 作者:太空宇宙 更新时间:2023-11-03 11:25:56 25 4
gpt4 key购买 nike

我一直在寻找 ReSTLet 提供的源代码 official tutorial .

我正在尝试使用教程中的 Android 应用程序访问 ReSTLet 服务器,但我只得到 JSON 响应,而不是 Java 对象。我尝试使用所有库和扩展,但没有任何效果。但是,当我点击教程网址 ( http://restlet-example-serialization.appspot.com/contacts/123 ) 时,我得到了所需的响应。有任何想法吗?顺便说一句,我只是在示例中使用服务器 (GAE),而不是 GWT 前端。

最佳答案

使用 GSOn 将 json 转换为 java 对象。您可以从谷歌获取 GSON 作为其代码:

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

其他方式:

Response res = client.handle(req); 
ObjectRepresentation<Item> obj = new ObjectRepresentation<Item>(res.getEntity());
Item item = obj.getObject();

关于android - RESTlet 教程应用程序不返回 Java 对象(仅限 JSON),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4182820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com