Last active
October 26, 2016 20:18
-
-
Save patrykpoborca/496832788134460906304695aced7555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeToken<Map<String, String>> mapType = new TypeToken<Map<String, String>>() { | |
}; | |
new TypeAdapterFactory() { | |
@Override | |
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { | |
if(type.equals(mapType)) { | |
return new TypeAdapter<T>() { | |
@Override | |
public void write(JsonWriter out, T value) throws IOException { | |
} | |
@Override | |
public T read(JsonReader in) throws IOException { | |
if(blah) { | |
return (T) gson.fromJson(in, new TypeToken<HashMap<String, String>>(){}.getType()); | |
} | |
else { | |
return (T) gson.fromJson(in, new TypeToken<TreeMap<String, String>>(){}.getType()); | |
} | |
} | |
}; | |
} | |
return null; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment