这是我第一次处理类型映射,每次我尝试将节点映射到我的实际类型对象,它有一个自定义属性键作为 FooType 和一个Set<Integer>
值。这是我的对象的样子
public class Foo {
private String some;
Map<FooTypes,Set<Integer>> foos;
public Map<FooTypes, Set<Integer>> getFoos() {
return foos;
}
public void setFoos(Map<FooTypes, Set<Integer>> map) {
this.foos = map;
}
public String getSome() {
return some;
}
public void setSome(String some) {
this.some = some;
}
}
public class FooTypes {
private String name;
private String id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
现在每次我尝试使用映射器来读取值:-
List <Foo> response = mapper.readValue("/home/foo/foo.json",List.class);
我收到一条错误消息:-
Can not find a (Map) Key deserializer for type [simple type, class cruft.FooTypes]
有人可以告诉我如何解决这个问题吗?谢谢你。
json输出:-
{"foos":{"FooTypes [id=1, name=Test Foo]":[1,2,3]},"some":hello},{"foos":{"FooTypes [id=2, name=Another foo]":[5,6,7]}}