有人能帮我为下面的json 设计pojo类吗
"t_details":{
// this numeric value is dynamic value from server
"980303030303": {
"key1": "27389237482744",
"key2": ""
}
}`
我需要为上面提到的json创建响应类(Getter Setter(,其中KEY是动态值
为此,您可以为JSON对象的每对创建HasMap。像下面的
class YourModel {
Map<String, DataModel> data = new HashMap <String, DataModel>();
public void setValue(Map<String, DataModel> map)
{
this.data = map;
}
public Map<String, DataModel> getValue()
{
return this.data;
}
}
您的内部数据模型
class DataModel {
@SerializedName("key1")
@Expose
private String key1;
@SerializedName("key2")
@Expose
private String key2;
public String getKey1() {
return key1;
}
public void setKey1(String key1) {
this.key1 = key1;
}
public String getKey2() {
return key2;
}
public void setKey2(String key2) {
this.key2 = key2;
}
}