Java tutorial
//package com.java2s; //License from project: Apache License import com.google.gson.Gson; public class Main { private static Gson gson = new Gson(); public static <T> T fromJson(String jsonInString, Class<T> responseType) { try { if (jsonInString == null || !jsonInString.isEmpty()) { return (T) gson.fromJson(jsonInString, responseType); } return null; } catch (Exception ex) { return null; } } }