com.envisioniot.enos.enosapi.common.util.JsonParser Maven / Gradle / Ivy
/**
* Project: eeop
*
* Copyright http://www.envisioncn.com/ All rights reserved.
*
* @author xiaomin.zhou
*/
package com.envisioniot.enos.enosapi.common.util;
import com.google.gson.Gson;
import java.lang.reflect.Type;
/**
* Json Parser
*/
public class JsonParser {
private static final Gson gson = new Gson();
//Dummy Constructor
private JsonParser() {
}
//Json To Object By Gson
public static T fromJson(String json, Class classOfT) {
return gson.fromJson(json, classOfT);
}
//Json To Object By Gson
public static T fromJson(String json, Type typeOfT) {
return gson.fromJson(json, typeOfT);
}
//Object To Json By Gson
public static String toJson(Object object) {
return gson.toJson(object);
}
}