我正在使用使用HAL (Hypertext Application Language)的api,在某些回复中,它包含
等字段"_links": {
"self": { "href": "/account" },
"numbers": { "href": "/numbers" },
"menus": { "href": "/menus" },
"applications": { "href": "/applications" },
"messages": { "href": "/messages" }
},
这是hal的一部分。我搜索并找到了halarious库并尝试将其与我的改装API集成。转换的POJO是:
public class User {
@Expose(serialize = false, deserialize = true)
@HalLink
private String links;
@SerializedName("id")
private String mRemoteId;
@SerializedName("name")
private String mName;
}
并且gson和retrofit配置为:
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new HalDeserializer(AccountResponse.class))
.create();
RestAdapter restAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL)
.setEndpoint(BASE_URL)
.setConverter(new UsersConverter())
.build();
我想知道我接下来应该做些什么呢?