|
@@ -23,6 +23,7 @@ import java.util.Map;
|
|
*/
|
|
*/
|
|
public class JsonUtil {
|
|
public class JsonUtil {
|
|
private static final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
|
private static final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
|
|
|
+ private static final Gson gson2 = new GsonBuilder().serializeNulls().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
|
|
|
|
|
public JsonUtil() {
|
|
public JsonUtil() {
|
|
}
|
|
}
|
|
@@ -37,6 +38,15 @@ public class JsonUtil {
|
|
return gson.toJson(object);
|
|
return gson.toJson(object);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 转换为json字符串 允许为null
|
|
|
|
+ *
|
|
|
|
+ * @param object 对象
|
|
|
|
+ * @return {@link String}
|
|
|
|
+ */
|
|
|
|
+ public static String toJsonStrNullAble(Object object) {
|
|
|
|
+ return gson2.toJson(object);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 将json字符串 转换为 普通类
|
|
* 将json字符串 转换为 普通类
|