我有一个 JSON 字符串,我想将它反序列化为一个带有接口数据成员的 Java 对象。Java 对象如下所示:
public class Person {
private String id;
private String name;
private AddressInterface addr;
}
Person 和 AddressInterface 都是第三方类,所以我无法对它们进行任何更改。
当我使用以下反序列化 JSON 字符串时,
objectMapper.readValue(json_file, Person.class)
我得到以下异常。这是因为对象映射器不知道如何反序列化 AddressInterface 字段。在这种情况下,有人可以让我知道如何将字符串反序列化为 Person 对象吗?非常感谢。
abstract types either need to be mapped to
concrete types, have custom deserializer,
or be instantiated with additional type information
摇曳的蔷薇
呼如林
Smart猫小萌
相关分类