Created
May 15, 2019 15:05
-
-
Save esabook/94f7fdc19ac939256dc4c332863c384d to your computer and use it in GitHub Desktop.
gson string deserializer
This file contains 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
public class StringDeserializer implements JsonDeserializer<String> { | |
@Override | |
public String deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | |
if (json.isJsonObject()) { | |
return json.toString(); | |
} else { | |
return json.getAsString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment