I am trying to parse the following response using gson in my android app:
{
"richerich":{
"id":19250176,
"name":"RichERich",
"profileIconId":744,
"summonerLevel":30,
"revisionDate":1425977347000
}
"alma":{
"id":19250174,
"name":"Alma",
"profileIconId":764,
"summonerLevel":30,
"revisionDate":14259773423424
}
}
The key "richeric" is a dynamic key and may change, and i can also have other response objects like "richeric" in my response string.
I create classes for this:
public class SummonerDto {
private long id;
private String name;
private int profileIconId;
private long revisionDate;
private long summonerLevel;
//getters, setters...
}
and my response class:
public class SummonerInfoResponse {
private Map<String, SummonerDto> summoners;
public Map<String, SummonerDto> getSummoners() {
return summoners;
}
public void setSummoners(Map<String, SummonerDto> summoners) {
this.summoners = summoners;
}
}
and i use the following piece of code:
return gson.fromJson(response, SummonerInfoResponse.class);
but it returns null. Can anyone tell me why?
Thanks.