You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
对象中包含 Date 类型的属性,通过 @JSONField 指定格式化,当 Date 类型的属性值为 "",parseObject 会报错;当 Date 类型的属性为 null,parseObject 正常
Fastjson 1.2.83 没有这个问题
环境信息
版本信息:[Fastjson2 2.0.7]
重现步骤
使用 JSON.parseObject 方法
输入 {"date":""} 数据
出现 Text '' could not be parsed at index 0 错误
@JSONField(format = "yyyy-MM-dd")
private Date date;
相关日志输出
Exception in thread "main" java.time.format.DateTimeParseException: Text '' could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.LocalDate.parse(LocalDate.java:400)
at com.alibaba.fastjson2.reader.ObjectReaderImplDate.readDate(ObjectReaderImplDate.java:105)
at com.alibaba.fastjson2.reader.ObjectReaderImplDate.readObject(ObjectReaderImplDate.java:71)
at com.alibaba.fastjson2.reader.ObjectReader_1.readObject(Unknown Source)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:421)
The text was updated successfully, but these errors were encountered:
问题描述
对象中包含 Date 类型的属性,通过 @JSONField 指定格式化,当 Date 类型的属性值为 "",parseObject 会报错;当 Date 类型的属性为 null,parseObject 正常
Fastjson 1.2.83 没有这个问题
环境信息
重现步骤
JSON.parseObject
方法{"date":""}
数据Text '' could not be parsed at index 0
错误相关日志输出
The text was updated successfully, but these errors were encountered: