Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

public class Main {
    public static <T> T jsonToObject(String json, Class<T> c) {
        T t = null;
        if (!TextUtils.isEmpty(json)) {
            try {
                t = new Gson().fromJson(json, c);
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
        return t;
    }
}