Skip to content

Instantly share code, notes, and snippets.

@daichan4649
Created December 9, 2014 04:42
Show Gist options
  • Save daichan4649/4407ee218f30f317fdfc to your computer and use it in GitHub Desktop.
Save daichan4649/4407ee218f30f317fdfc to your computer and use it in GitHub Desktop.
gson sample (JSON -> model)
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