FastJson 自定义反序列化类
2021-05-07 14:28
标签:ack not parser link orm swa poj pac dem
* 测试类
* FastJson 自定义反序列化类 标签:ack not parser link orm swa poj pac dem 原文地址:https://www.cnblogs.com/seliote/p/12088661.html反序列化类
package com.seliote.demo.test;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import org.springframework.util.Assert;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.LinkedList;
import java.util.List;
/**
* FastJson 时间格式自定义反序列化类
*
* @author LiYangDi
* @since 2019/12/23
*/
public class FastJsonLocalDateTimeDeserializer implements ObjectDeserializer {
private static List
测试
POJO
package com.seliote.demo.pojo;
import com.alibaba.fastjson.annotation.JSONField;
import com.seliote.demo.test.FastJsonLocalDateTimeDeserializer;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 测试 POJO
*
* @author LiYangDi
* @since 2019/12/23
*/
@Data
public class Pojo {
@JSONField(name = "time", deserializeUsing = FastJsonLocalDateTimeDeserializer.class)
//@JSONField(name = "time")
private LocalDateTime localDateTime;
@JSONField(name = "name")
private String name;
}
测试类
package com.seliote.demo.test;
import com.alibaba.fastjson.JSONObject;
import com.seliote.demo.pojo.Pojo;
import lombok.extern.slf4j.Slf4j;
/**
*
下一篇:webpack中的加载器