Code example for Gson

Methods: fromJson

0
class ModelJson { 
  // TODO(kevinb): options? 
  private static final Gson GSON = new GsonBuilder().create();
 
  static <T> T fromJson(String json, Class<T> type) {
    return GSON.fromJson(json, type);
  } 
 
  static String toJson(Object obj) {
    return GSON.toJson(obj);
  } 
 
  static String toJson(JsonElement element) {
    return GSON.toJson(element);
  } 
}