非字符串映射鍵我有機管局地圖,看起來像這樣:反序列化與傑克遜
public class VerbResult {
@JsonProperty("similarVerbs")
private Map<Verb, List<Verb>> similarVerbs;
}
我動詞類看起來是這樣的:
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);
}
//...
}
我想序列化和反序列化的情況下,我VerbResult類,但當我做我得到這個錯誤:Can not find a (Map) Key deserializer for type [simple type, class my.package.Verb]
我在網上讀到,你需要告訴傑克遜如何反序列化映射鍵,但我沒有找到任何信息解釋如何去做這件事。動詞類需要在地圖之外進行序列化和反序列化,因此任何解決方案都應該保留此功能。
謝謝你的幫助。
作品有你讀http://stackoverflow.com/questions/6371092/can-not-find-a-map-key-deserializer-for-type -simple-type-class-com-comcast-i?他的情況看起來與你的一見鍾情。 – fvu
是的,我已經閱讀過,但實際上我沒有找到答案。我怎樣才能使用模塊來解決這個問題? – Max