I\'m requesting data from a server which returns data in the JSON format. Casting a HashMap into JSON when making the request wasn\'t hard at all but the other way seems to
Below is supported since gson 2.8.0
public static Type getMapType(Class keyType, Class valueType){
return TypeToken.getParameterized(HashMap.class, keyType, valueType).getType();
}
public static HashMap fromMap(String json, Class keyType, Class valueType){
return gson.fromJson(json, getMapType(keyType,valueType));
}