我正在构建一个 android 应用程序,用于保存类中传入/传出呼叫、CallLog类中传入/传出 SMSSmsLog以及通过类发送/接收的字节的信息DataLog。我让它们都实现了一个JsonLog接口,这样我就可以创建一个s ArrayList,JsonLog希望它可以通过 Jackson 轻松转换为不同对象的 JSON 数组。
但是,每当我反序列化 JSON 文件时,我都会收到此错误:
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance
of com.project.pojos.JsonLog, problem: abstract types either need to be mapped
to concrete types, have custom deserializer, or be instantiated with additional
type information
我该如何解决这个问题?所有JsonLog类都有一个字符串属性type,它是in_callor out_callfor CallLogs, in_smsor out_smsfor SmsLogs, and datafor DataLog。