com.gitee.huanminabc.utils_common.json.JsonGsonUtils Maven / Gradle / Ivy
package com.gitee.huanminabc.utils_common.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.gitee.huanminabc.utils_common.base.UniversalException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class JsonGsonUtils {
private static Gson gson ;
static {
GsonBuilder gsonBuilder = new GsonBuilder() ;
// 设置成漂亮的输出
// gsonBuilder.setPrettyPrinting();
//设定日期解析格式
gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss");
gson=gsonBuilder.create();
}
//把json 字符串 转换为 Map
public static Map jsonTurnMap(String json){
Map res = null;
try {
res = gson.fromJson(json, new TypeToken