我有一个具有Map的域对象:
private Map<AutoHandlingSlotKey, LinkedHashSet<AutoFunction>> autoHandling;
Run Code Online (Sandbox Code Playgroud)
当我序列化对象时,我得到了这个:
"autoHandling" : [ "java.util.HashMap", {
} ],
Run Code Online (Sandbox Code Playgroud)
这个Map的关键是一个自定义对象:
public class AutoHandlingSlotKey implements Serializable {
private FunctionalArea slot; // ENUM
private String returnView; // ENUM
Run Code Online (Sandbox Code Playgroud)
所以,我不确定如何纠正我在反序列化对象时遇到的这个问题:
org.codehaus.jackson.map.JsonMappingException: Can not find a (Map) Key deserializer for type [simple type, class com.comcast.ivr.core.domain.AutoHandlingSlotKey]
Run Code Online (Sandbox Code Playgroud)
如果我没有访问域对象进行修改,有人可以帮助我理解如何纠正这个问题吗?
我有一个看起来像这样的地图:
public class VerbResult {
@JsonProperty("similarVerbs")
private Map<Verb, List<Verb>> similarVerbs;
}
Run Code Online (Sandbox Code Playgroud)
我的动词类看起来像这样:
public class Verb extends Word {
@JsonCreator
public Verb(@JsonProperty("start") int start, @JsonProperty("length") int length,
@JsonProperty("type") String type, @JsonProperty("value") VerbInfo value) {
super(length, length, type, value);
}
//...
}
Run Code Online (Sandbox Code Playgroud)
我想序列化和反序列化我的VerbResult类的实例,但是当我这样做时,我得到这个错误: Can not find a (Map) Key deserializer for type [simple type, class my.package.Verb]
我在网上看到你需要告诉杰克逊如何反序列化地图密钥,但我没有找到任何解释如何进行此操作的信息.动词类也需要在地图之外进行序列化和反序列化,因此任何解决方案都应保留此功能.