-
Notifications
You must be signed in to change notification settings - Fork 550
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
问题描述
对象中包含 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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working