Flexjson LocalDate反序列化问题

时间:2018-07-03 14:25:24

标签: flexjson

我有以下json:

[{"id":1,"deadline":{"year":2020,"month":"NOVEMBER","era":"CE","dayOfMonth":22,"dayOfWeek":"SUNDAY","dayOfYear":327,"leapYear":true,"monthValue":11,"chronology":{"id":"ISO","calendarType":"iso8601"}}]

反序列化json时出现异常

flexjson.JSONException: [ values.deadline ]:  Parsing date {dayOfWeek=SUNDAY, month=NOVEMBER, year=2020, era=CE, dayOfMonth=22, dayOfYear=327, monthValue=11, chronology={calendarType=iso8601, id=ISO}, leapYear=true} was not recognized as a date format`

我的序列化代码如下:

List<CollaborationTask> result = (List<CollaborationTask>) new JSONDeserializer<List<CollaborationTask>>()
                                                                    .use(null, ArrayList.class)
                                                                    .use("values",CollaborationTask.class)
                                                                    .use(LocalDate.class, new DateObjectFactory())
                                                                    .deserialize( response.getBody());

我知道DateObjectFactory不适合Date类。我也在寻找一种有关如何通过LocalDateObjectFactory实例化LocalDate的解决方案,但我找不到任何示例。

有什么想法我们可以反序列化lodaDates吗?

提前谢谢

0 个答案:

没有答案