[alibaba/fastjson]年份大于10000时反序列化出错

2025-11-11 344 views
1

fastjson版本:1.2.47

这个在jackson中,dto的字段声明为java.util.Date类型,是可以进行序列化/反序列化的

纠正一下,在jackson里是有去无回,只能序列化,不能反序列化

Caused by: java.lang.NumberFormatException: For input string: "10007-06-07T00:00:00.000+08"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:589)
    at java.lang.Long.parseLong(Long.java:631)
    at com.alibaba.fastjson.serializer.DateCodec.cast(DateCodec.java:244)
    at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:138)
    at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:15)
    at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:86)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:1078)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:773)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseRest(JavaBeanDeserializer.java:1283)
    at com.alibaba.fastjson.parser.deserializer.FastjsonASMDeserializer_30_BankBillMonthInfo.deserialze(Unknown Source)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:267)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:747)
    at com.alibaba.fastjson.serializer.CollectionCodec.deserialze(CollectionCodec.java:129)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:661)
    ... 25 common frames omitted

回答

2

这个是无法处理的哦

8

我们一般都是设置成9999-12-31 @PuGuanyu

3

现在是遇到别人用jackson可以进行正常的序列化/反序列化,我们这边没法要求对方修改数据

3

这种数据应该是算合法的数据,看起来JS也可以正常的支持

6

纠正一下,在jackson里是有去无回,只能序列化,不能反序列化