0

Can someone please help me to design pojo class for following json

     "t_details":{
              // this numeric value is dynamic value from server
        "980303030303": {  
      "key1": "27389237482744",
       "key2": ""
         }
         }`

I need to make Response Class (Getter Setter) for above mentioned json in which KEY is dynamic value

S.Ambika
  • 292
  • 1
  • 14

1 Answers1

0

For this, you can create HasMap for each pair for JSON Object. Like below

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;
       }
    }

Your Inner data model

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;
    }
}
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50