I have some request with the same endpoint but parameter and return type are different.
I used @QueryMap for the parameter but I don't know how to write the return type:
Must I write:
@GET("xxx")
Call<List<A1>> groupList1(@QueryMap Map<String, String> options);
@GET("xxx")
Call<List<A2>> groupList2(@QueryMap Map<String, String> options);
@GET("xxx")
Call<List<A3>> groupList3(@QueryMap Map<String, String> options);
....
or there is a shorter solution?
You can use JsonElement response type
@GET("xxx")
Call<JsonElement> groupList(@QueryMap Map<String, String> options);
Every call you will receive JsonElement which you can convert to JsonObject or JsonArray or even String. You can parse/deserealize it according to the your content
public void onResponse(Call<JsonElement> call, Response<JsonElement> response) {
JsonElement jsonElement = response.body();
//JsonArray array = jsonElement.getAsJsonArray();
//JsonObject Obj = jsonElement .getAsJsonObject();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With