import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description : 自定义工具类(逐步完善)
* @Time :2019-04-22 14:12
*/
public final class JsonUtil {
/**
* 单例 ObjectMapper
*/
private final static ObjectMapper objectMapper = new ObjectMapper();
static {
// 全部字段序列化
//对象的所有字段全部列入
objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
//取消默认转换timestamps形式
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
//允许非引号字段名
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
//所有的日期格式都统一为以下
json字符串转换-JsonUtil
于 2020-07-13 20:46:00 首次发布