子类的Jackson(反)序列化

时间:2018-08-01 20:50:01

标签: java jackson

我可以反序列化此类的对象:

public class MyCoolClass {
    public UUID uuid;
    public String name;
    public BookingPeriod openPeriod;
}

但是,一旦我扩展,它就会崩溃:

public class MyCoolClass extends TreeSet<Table> {
    // ...same
}

TreeSet与实现有关。

我发现的异常是:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `test.MyCoolClass` out of START_OBJECT token
 at [Source: (String)"{
  "uuid": "e64c15af-adb0-437e-9fb8-7ad7e793b877",
  "name": "Something-That-Can-Be-Opened",
  "openPeriod": {
    "from": "19:30",
    "to": "23:30"
  }
}"; line: 1, column: 1]

在不继承的情况下使用,程序将按预期运行。

“ 19:30” 反序列化为LocalTime

0 个答案:

没有答案