Restlet看起来很酷,但很抱歉,由于缺少简单客户的文档,我只是整天都在敲头。
我设法从
中获取了一些有用的东西http://restlet.org/learn/guide/2.1/core/resource/client
但实际上没有任何东西可以作为完整下载(这将是很好的)。例如,客户在这里只是一个pojo?或者必须实现Serializable(我认为必须)。
我的具体问题如下:
我有一些代码可以调用URL并获取此信息:
{"result":"success","data":{"last_local":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last_orig":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last_all":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"buy":{"value":"889.00000","value_int":"88900000","display":"$889.00","display_short":"$889.00","currency":"USD"},"sell":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"now":"1388846889233438"}}
我正在苦苦挣扎的是,MAGIC发生如下:
ClientResource cr = new ClientResource(….); // fine
IDataStruct resource = cr.wrap(IDataStruct.class); // <---- Magic here, but fine at Runtime.
if(cr.getResponse().getStatus().isSuccess()) // fine
{
PriceObject price = resource.retrieve();//<--- get to this line but then everything blows up because no converter is found. I can't use Jackson because GAE does not like it
}
问题是, IDataStruct 界面应该是什么样的?
威尔
答案 0 :(得分:0)
示例中的客户确实是POJO。根据您使用的转换器,您可以将其设置为可序列化。顺便说一句,杰克逊应该在GAE上工作,你遇到过哪个问题?
IDataStruct应该是一个使用Restlet API注释注释的Java接口,例如@ Get,@ Post等。
关于用户指南,您可以在GitHub中找到已编辑的版本,我刚刚修复了一些损坏的链接(很快将在Restlet.org上发布): https://github.com/restlet/restlet-sites/blob/master/modules/org.restlet/learn/guide/2.1/introduction/first-steps/first-client.md