我正在使用以下映射器
ObjectMapper mapper = new ObjectMapper ();
mapper.configure(Feature.WRAP_ROOT_VALUE, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
将以下类序列化为JSON
public class MyList {
@JsonProperty("samples")
List<Module> sampleList;
public List<Module> getSampleList() {
return sampleList;
}
public void setSampleList(List<Sample> sampleList) {
this.sampleList = sampleList;
}
}
但我得到以下输出:
{"MyList ":{"samples":[ ... ]}}
但我不想要这个MyList
。我期待着:
"samples":[...]
如果只明确指定了根目录,我怎么能告诉杰克逊呢?