You can make your POJO model contain Map<String, Champion>deserialization to handle dynamic keys.
Example:
public class ChampionData {
public Map<String, Champion> data;
public String type;
public String version;
}
public class Champion {
public int id;
public String title;
public String name;
public String key;
}
I am not familiar with Retrofit yet, but as someone said in the comments, Gson deserializes:
public ChampionData champions = new Gson().fromJson(json, ChampionData.class);
So, to respond to a response sent by another user, you can do the following: if you added GsonConverterFactory:
public interface API {
@GET("path/to/endpoint")
Call<ChampionData> getChampionData();
}
source
share