package com.wasu.cs.utils;

/**
 * Created by Danxx on 2016/5/26.
 */
import com.google.gson.Gson;

import java.lang.reflect.Type;

//JSON的编码和解码类
public class JsonUtil {
    private static Gson gson = new Gson();

    //JSON编码
    public static String toJson(Object objdata) {
        return gson.toJson(objdata);
    }

    //JSON解码
    public static <T> T fromJson(String json, Class<T> classOfT){
        return gson.fromJson(json, classOfT);
    }

    public static <T> T fromJson(String json, Type typeOfT){
        return gson.fromJson(json, typeOfT);
    }

}
