【发布时间】:2012-09-11 09:55:04
【问题描述】:
我正在构建一个 android 应用程序,它将传入/传出呼叫的信息保存在 CallLog 类中,传入/传出短信在 SmsLog 类中,以及通过 DataLog 类发送/接收的字节数。我让它们都实现了一个JsonLog 接口,因此我可以创建一个JsonLogs 的ArrayList,希望它可以通过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,对于CallLogs,它是in_call 或out_call,对于in_sms 或in_sms,对于SmsLogs,data 对于@987654@33 .
【问题讨论】: