4

I'm working with an api that uses HAL (Hypertext Application Language) and in some responses it includes fields like

"_links": {
    "self": { "href": "/account" },
    "numbers": { "href": "/numbers" },
    "menus": { "href": "/menus" },
    "applications": { "href": "/applications" },
    "messages": { "href": "/messages" }
},

that is a part of hal. I had searched and found halarious library and trying to integrate it with my retrofit api. The POJO that is converted is:

public class User {
    @Expose(serialize = false, deserialize = true)
    @HalLink
    private String links;

    @SerializedName("id")
    private String mRemoteId;

    @SerializedName("name")
    private String mName;
}

and the gson and retrofit config is:

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

I want to know what should i do next to have this work?

Morteza Rastgoo
  • 6,772
  • 7
  • 40
  • 61
  • Creating a new Converter isn't that difficult, just look at the current code for the `GsonConverter` here: http://grepcode.com/file/repo1.maven.org/maven2/com.squareup.retrofit/retrofit/1.0.1/retrofit/converter/GsonConverter.java – EpicPandaForce May 06 '15 at 11:08
  • I used Halarious with Retrofit, you can see my code along with a question at http://stackoverflow.com/questions/33404734/ – Gabor Oct 29 '15 at 18:11

0 Answers0