Android Using Gson as serializer with Retrofit


Example

First of all you need to add the GsonConverterFactory to your build.gradle file

compile 'com.squareup.retrofit2:converter-gson:2.1.0'

Then, you have to add the converter factory when creating the Retrofit Service:

Gson gson = new GsonBuilder().create();
new Retrofit.Builder()
        .baseUrl(someUrl)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .build()
        .create(RetrofitService.class);

You can add custom converters when creating the Gson object that you are passing to the factory. Allowing you to create custom type conversions.