Created
December 9, 2014 04:42
-
-
Save daichan4649/4407ee218f30f317fdfc to your computer and use it in GitHub Desktop.
gson sample (JSON -> model)
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
public interface JsonModel { | |
// model | |
} | |
public class JsonUtil { | |
@SuppressWarnings("unchecked") | |
public static <T> T fromJson(String jsonText, Class<? extends JsonModel> T) { | |
Gson gson = new Gson(); | |
return (T) gson.fromJson(jsonText, T); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment