I'm trying to parse a JSON, using GSON, but there is a complex part, because I do not know the name of the keys, so I do not know what names to use in the variables for GSON to parse. I searched and it looks like I have to use Map < & gt ;, but even so I can not.
JSON example:
{
"type": "typeString",
"format": "json",
"version": "4.13.35",
"data": {
"data1": {
"version": "4.13.1",
"id": "data1",
"key": "238",
"name": "John"
},
"data2": {
"version": "4.13.1",
"id": "data2",
"key": "115",
"name": "Hello"
},
"data3": {
"version": "4.13.1",
"id": "date3",
"key": "26",
"name": "Zeus"
},
"data4": {
"version": "4.13.1",
"id": "data4",
"key": "143",
"name": "Venus"
}
}
}
Class made:
public class MasterGSON {
@SuppressWarnings("type")
private String type;
@SuppressWarnings("format")
private String format;
@SuppressWarnings("version")
private String version;
@SuppressWarnings("data")
private Map<String, DataGSON> listChampion;
public Map<String, DataGSON> getListChampion() {
return listChampion;
}
public String getType() {
return type;
}
public String getFormat() {
return format;
}
public String getVersion() {
return version;
}
public class DataGSON {
private String version;
private String id;
private String key;
private String name;
public String getVersion() {
return version;
}
public String getId() {
return id;
}
public String getKey() {
return key;
}
public String getName() {
return name;
}
}
}
Can someone help me?