com.zcj.util.json.gson.GsonInstanceFox Maven / Gradle / Ivy
package com.zcj.util.json.gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zcj.util.json.gson.deserializer.GsonCollectionDeserializer;
import com.zcj.util.json.gson.deserializer.GsonDateDeserializer;
import com.zcj.util.json.gson.deserializer.GsonNumberDeserializer;
import com.zcj.util.json.gson.serializer.GsonSpringFoxSerializer;
import springfox.documentation.spring.web.json.Json;
import java.util.Collection;
import java.util.Date;
public class GsonInstanceFox {
public static final Gson GSON_FOX = new GsonBuilder()
.registerTypeAdapter(Date.class, new GsonDateDeserializer())
.registerTypeHierarchyAdapter(Number.class, new GsonNumberDeserializer())
.registerTypeHierarchyAdapter(Collection.class, new GsonCollectionDeserializer())
.registerTypeAdapter(Json.class, new GsonSpringFoxSerializer())
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
public static final Gson GSON_FOX_SERIALIZE_NULL = new GsonBuilder()
.serializeNulls()
.registerTypeAdapter(Date.class, new GsonDateDeserializer())
.registerTypeHierarchyAdapter(Number.class, new GsonNumberDeserializer())
.registerTypeHierarchyAdapter(Collection.class, new GsonCollectionDeserializer())
.registerTypeAdapter(Json.class, new GsonSpringFoxSerializer())
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
}